[PATCH] csa: Extended system accounting over taskstats
authorJay Lan <jlan@engr.sgi.com>
Sun, 1 Oct 2006 06:28:58 +0000 (23:28 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 1 Oct 2006 07:39:29 +0000 (00:39 -0700)
Add extended system accounting handling over taskstats interface.  A
CONFIG_TASK_XACCT flag is created to enable the extended accounting code.

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

index af93a63a509202c6e35b5f5e7268f8f72a9b9c30..3d2c304886b03e4361bb33a2371807fa7f194afd 100644 (file)
@@ -107,6 +107,17 @@ struct taskstats {
        __u64   ac_minflt;              /* Minor Page Fault */
        __u64   ac_majflt;              /* Major Page Fault */
        /* Basic Accounting Fields end */
+
+       /* Extended accounting fields start */
+       __u64   acct_rss_mem1;          /* accumulated rss usage */
+       __u64   acct_vm_mem1;           /* accumulated virtual memory usage */
+       __u64   hiwater_rss;            /* High-watermark of RSS usage */
+       __u64   hiwater_vm;             /* High-water virtual memory usage */
+       __u64   read_char;              /* bytes read */
+       __u64   write_char;             /* bytes written */
+       __u64   read_syscalls;          /* read syscalls */
+       __u64   write_syscalls;         /* write syscalls */
+       /* Extended accounting fields end */
 };
 
 
index 7e8196a021182c4682e0024e181da5c3ea73ff91..74102dcae67a6d51dba2a866705f88ceaee87b1c 100644 (file)
@@ -16,4 +16,13 @@ static inline void bacct_add_tsk(struct taskstats *stats, struct task_struct *ts
 {}
 #endif /* CONFIG_TASKSTATS */
 
+#ifdef CONFIG_TASK_XACCT
+extern void xacct_add_tsk(struct taskstats *stats, struct task_struct *p);
+#else
+static inline void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
+{}
+#endif /* CONFIG_TASK_XACCT */
+
 #endif
+
+
index d2d72704f8754f0ba373fe4186cfb0b37fb1bd7c..f7a04d0daf077450e95926d68a4cb0ae52547c7e 100644 (file)
@@ -257,6 +257,15 @@ config CC_OPTIMIZE_FOR_SIZE
 
          If unsure, say N.
 
+config TASK_XACCT
+       bool "Enable extended accounting over taskstats (EXPERIMENTAL)"
+       depends on TASKSTATS
+       help
+         Collect extended task accounting data and send the data
+         to userland for processing over the taskstats interface.
+
+         Say N if unsure.
+
 config SYSCTL
        bool
 
index 6c38dce88e8c4e4eb60f1efad93e5628bb53281f..5d6a8c54ee85f56f9a3640480d5560ed35f2b4e5 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/taskstats_kern.h>
 #include <linux/tsacct_kern.h>
 #include <linux/delayacct.h>
+#include <linux/tsacct_kern.h>
 #include <linux/cpumask.h>
 #include <linux/percpu.h>
 #include <net/genetlink.h>
@@ -204,6 +205,9 @@ static int fill_pid(pid_t pid, struct task_struct *pidtsk,
        stats->version = TASKSTATS_VERSION;
        bacct_add_tsk(stats, tsk);
 
+       /* fill in extended acct fields */
+       xacct_add_tsk(stats, tsk);
+
        /* Define err: label here if needed */
        put_task_struct(tsk);
        return rc;
index 899067950a8819c7231a28092a7f5ebb95927a5e..410483490cf6c1e7756f3381dbc49090eea3fdaa 100644 (file)
@@ -70,3 +70,22 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
        strncpy(stats->ac_comm, tsk->comm, sizeof(stats->ac_comm));
 }
 
+
+#ifdef CONFIG_TASK_XACCT
+/*
+ * fill in extended accounting fields
+ */
+void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
+{
+       stats->acct_rss_mem1 = p->acct_rss_mem1;
+       stats->acct_vm_mem1  = p->acct_vm_mem1;
+       if (p->mm) {
+               stats->hiwater_rss   = p->mm->hiwater_rss;
+               stats->hiwater_vm    = p->mm->hiwater_vm;
+       }
+       stats->read_char        = p->rchar;
+       stats->write_char       = p->wchar;
+       stats->read_syscalls    = p->syscr;
+       stats->write_syscalls   = p->syscw;
+}
+#endif