Commit 9acc1853519a0473620d424105f9d49ea5b4e62e
Committed by
Linus Torvalds
1 parent
f3cef7a994
Exists in
master
and in
4 other branches
[PATCH] csa: Extended system accounting over taskstats
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>
Showing 5 changed files with 52 additions and 0 deletions Side-by-side Diff
include/linux/taskstats.h
... | ... | @@ -107,6 +107,17 @@ |
107 | 107 | __u64 ac_minflt; /* Minor Page Fault */ |
108 | 108 | __u64 ac_majflt; /* Major Page Fault */ |
109 | 109 | /* Basic Accounting Fields end */ |
110 | + | |
111 | + /* Extended accounting fields start */ | |
112 | + __u64 acct_rss_mem1; /* accumulated rss usage */ | |
113 | + __u64 acct_vm_mem1; /* accumulated virtual memory usage */ | |
114 | + __u64 hiwater_rss; /* High-watermark of RSS usage */ | |
115 | + __u64 hiwater_vm; /* High-water virtual memory usage */ | |
116 | + __u64 read_char; /* bytes read */ | |
117 | + __u64 write_char; /* bytes written */ | |
118 | + __u64 read_syscalls; /* read syscalls */ | |
119 | + __u64 write_syscalls; /* write syscalls */ | |
120 | + /* Extended accounting fields end */ | |
110 | 121 | }; |
111 | 122 | |
112 | 123 |
include/linux/tsacct_kern.h
... | ... | @@ -16,5 +16,12 @@ |
16 | 16 | {} |
17 | 17 | #endif /* CONFIG_TASKSTATS */ |
18 | 18 | |
19 | +#ifdef CONFIG_TASK_XACCT | |
20 | +extern void xacct_add_tsk(struct taskstats *stats, struct task_struct *p); | |
21 | +#else | |
22 | +static inline void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) | |
23 | +{} | |
24 | +#endif /* CONFIG_TASK_XACCT */ | |
25 | + | |
19 | 26 | #endif |
init/Kconfig
... | ... | @@ -257,6 +257,15 @@ |
257 | 257 | |
258 | 258 | If unsure, say N. |
259 | 259 | |
260 | +config TASK_XACCT | |
261 | + bool "Enable extended accounting over taskstats (EXPERIMENTAL)" | |
262 | + depends on TASKSTATS | |
263 | + help | |
264 | + Collect extended task accounting data and send the data | |
265 | + to userland for processing over the taskstats interface. | |
266 | + | |
267 | + Say N if unsure. | |
268 | + | |
260 | 269 | config SYSCTL |
261 | 270 | bool |
262 | 271 |
kernel/taskstats.c
... | ... | @@ -20,6 +20,7 @@ |
20 | 20 | #include <linux/taskstats_kern.h> |
21 | 21 | #include <linux/tsacct_kern.h> |
22 | 22 | #include <linux/delayacct.h> |
23 | +#include <linux/tsacct_kern.h> | |
23 | 24 | #include <linux/cpumask.h> |
24 | 25 | #include <linux/percpu.h> |
25 | 26 | #include <net/genetlink.h> |
... | ... | @@ -203,6 +204,9 @@ |
203 | 204 | /* fill in basic acct fields */ |
204 | 205 | stats->version = TASKSTATS_VERSION; |
205 | 206 | bacct_add_tsk(stats, tsk); |
207 | + | |
208 | + /* fill in extended acct fields */ | |
209 | + xacct_add_tsk(stats, tsk); | |
206 | 210 | |
207 | 211 | /* Define err: label here if needed */ |
208 | 212 | put_task_struct(tsk); |
kernel/tsacct.c
... | ... | @@ -69,4 +69,24 @@ |
69 | 69 | |
70 | 70 | strncpy(stats->ac_comm, tsk->comm, sizeof(stats->ac_comm)); |
71 | 71 | } |
72 | + | |
73 | + | |
74 | +#ifdef CONFIG_TASK_XACCT | |
75 | +/* | |
76 | + * fill in extended accounting fields | |
77 | + */ | |
78 | +void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) | |
79 | +{ | |
80 | + stats->acct_rss_mem1 = p->acct_rss_mem1; | |
81 | + stats->acct_vm_mem1 = p->acct_vm_mem1; | |
82 | + if (p->mm) { | |
83 | + stats->hiwater_rss = p->mm->hiwater_rss; | |
84 | + stats->hiwater_vm = p->mm->hiwater_vm; | |
85 | + } | |
86 | + stats->read_char = p->rchar; | |
87 | + stats->write_char = p->wchar; | |
88 | + stats->read_syscalls = p->syscr; | |
89 | + stats->write_syscalls = p->syscw; | |
90 | +} | |
91 | +#endif |