lkml.org 
[lkml]   [2008]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] BSD acct: disk I/O accounting
Hello,

This patch make acct use I/O statistics gathered when
TASK_IO_ACCOUNTING is enabled. getrusage() already uses that statistics,
but also will be helpful to get access to disk I/O statistics through
traditional BSD accounting interface, because many userspace scripts
that process such information not yet adapted to new taskstats API.
Patch against 2.6.25.

Signed-off-by: Sergey Kononenko <sergk@sergk.org.ua>
---

diff -uprN a/include/linux/task_io_accounting_ops.h b/include/linux/task_io_accounting_ops.h
--- a/include/linux/task_io_accounting_ops.h 2008-04-17 02:49:44.000000000 +0000
+++ b/include/linux/task_io_accounting_ops.h 2008-04-22 16:42:17.000000000 +0000
@@ -21,6 +21,11 @@ static inline unsigned long task_io_get_
return p->ioac.read_bytes >> 9;
}

+static inline unsigned long task_io_get_inbytes(const struct task_struct *p)
+{
+ return p->ioac.read_bytes;
+}
+
static inline void task_io_account_write(size_t bytes)
{
current->ioac.write_bytes += bytes;
@@ -35,6 +40,11 @@ static inline unsigned long task_io_get_
return p->ioac.write_bytes >> 9;
}

+static inline unsigned long task_io_get_oubytes(const struct task_struct *p)
+{
+ return p->ioac.write_bytes;
+}
+
static inline void task_io_account_cancelled_write(size_t bytes)
{
current->ioac.cancelled_write_bytes += bytes;
@@ -56,6 +66,11 @@ static inline unsigned long task_io_get_
return 0;
}

+static inline unsigned long task_io_get_inbytes(const struct task_struct *p)
+{
+ return 0;
+}
+
static inline void task_io_account_write(size_t bytes)
{
}
@@ -65,6 +80,11 @@ static inline unsigned long task_io_get_
return 0;
}

+static inline unsigned long task_io_get_oubytes(const struct task_struct *p)
+{
+ return 0;
+}
+
static inline void task_io_account_cancelled_write(size_t bytes)
{
}
diff -uprN a/kernel/acct.c b/kernel/acct.c
--- a/kernel/acct.c 2008-04-17 02:49:44.000000000 +0000
+++ b/kernel/acct.c 2008-04-22 16:42:17.000000000 +0000
@@ -55,6 +55,7 @@
#include <linux/times.h>
#include <linux/syscalls.h>
#include <linux/mount.h>
+#include <linux/task_io_accounting_ops.h>
#include <asm/uaccess.h>
#include <asm/div64.h>
#include <linux/blkdev.h> /* sector_div */
@@ -504,8 +505,8 @@ static void do_acct_process(struct pid_n
ac.ac_majflt = encode_comp_t(pacct->ac_majflt);
ac.ac_exitcode = pacct->ac_exitcode;
spin_unlock_irq(&current->sighand->siglock);
- ac.ac_io = encode_comp_t(0 /* current->io_usage */); /* %% */
- ac.ac_rw = encode_comp_t(ac.ac_io / 1024);
+ ac.ac_io = encode_comp_t(task_io_get_inbytes(current) + task_io_get_oubytes(current));
+ ac.ac_rw = encode_comp_t(task_io_get_inblock(current) + task_io_get_oublock(current));
ac.ac_swaps = encode_comp_t(0);

/*

\
 
 \ /
  Last update: 2008-04-22 21:17    [W:0.531 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site