[PATCH] io-accounting: via taskstats
authorAndrew Morton <akpm@osdl.org>
Sun, 10 Dec 2006 10:19:53 +0000 (02:19 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Sun, 10 Dec 2006 17:55:41 +0000 (09:55 -0800)
Deliver IO accounting via taskstats.

Cc: Jay Lan <jlan@sgi.com>
Cc: Shailabh Nagar <nagar@watson.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Chris Sturtivant <csturtiv@sgi.com>
Cc: Tony Ernst <tee@sgi.com>
Cc: Guillaume Thouvenin <guillaume.thouvenin@bull.net>
Cc: David Wright <daw@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/taskstats.h
kernel/tsacct.c

index 15c64037be1bedc601414ebf16787f8e24b7b009..3fced4798255101b1ec8f19aeb5905cb449bc8d2 100644 (file)
@@ -31,7 +31,7 @@
  */
 
 
-#define TASKSTATS_VERSION      2
+#define TASKSTATS_VERSION      3
 #define TS_COMM_LEN            32      /* should be >= TASK_COMM_LEN
                                         * in linux/sched.h */
 
@@ -140,6 +140,12 @@ struct taskstats {
        __u64   read_syscalls;          /* read syscalls */
        __u64   write_syscalls;         /* write syscalls */
        /* Extended accounting fields end */
+
+#define TASKSTATS_HAS_IO_ACCOUNTING
+       /* Per-task storage I/O accounting starts */
+       __u64   read_bytes;             /* bytes of read I/O */
+       __u64   write_bytes;            /* bytes of write I/O */
+       __u64   cancelled_write_bytes;  /* bytes of cancelled write I/O */
 };
 
 
index 96f77013d3f038ea03b688c448e2ef69a77aee06..baacc36914152271e01343e5a4de233e7b8780ba 100644 (file)
@@ -96,6 +96,15 @@ void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
        stats->write_char       = p->wchar;
        stats->read_syscalls    = p->syscr;
        stats->write_syscalls   = p->syscw;
+#ifdef CONFIG_TASK_IO_ACCOUNTING
+       stats->read_bytes       = p->ioac.read_bytes;
+       stats->write_bytes      = p->ioac.write_bytes;
+       stats->cancelled_write_bytes = p->ioac.cancelled_write_bytes;
+#else
+       stats->read_bytes       = 0;
+       stats->write_bytes      = 0;
+       stats->cancelled_write_bytes = 0;
+#endif
 }
 #undef KB
 #undef MB