diff options
author | Maxim Uvarov <muvarov@ru.mvista.com> | 2007-07-16 02:40:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-16 12:05:46 -0400 |
commit | b663a79c191508f27cd885224b592a878c0ba0f6 (patch) | |
tree | 270a0472bf1fb0c7323ecb60ec68e40d02dcb1b4 /fs | |
parent | a6c15c2b0fbfd5c0a84f5f0e1e3f20f85d2b8692 (diff) |
taskstats: add context-switch counters
Make available to the user the following task and process performance
statistics:
* Involuntary Context Switches (task_struct->nivcsw)
* Voluntary Context Switches (task_struct->nvcsw)
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).
This data is useful for detecting hyperactivity patterns between processes.
[akpm@linux-foundation.org: cleanup]
Signed-off-by: Maxim Uvarov <muvarov@ru.mvista.com>
Cc: Shailabh Nagar <nagar@watson.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Jay Lan <jlan@engr.sgi.com>
Cc: Jonathan Lim <jlim@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/proc/array.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c index 680c913575f0..9cbab7e93557 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -289,6 +289,15 @@ static inline char *task_cap(struct task_struct *p, char *buffer) | |||
289 | cap_t(p->cap_effective)); | 289 | cap_t(p->cap_effective)); |
290 | } | 290 | } |
291 | 291 | ||
292 | static inline char *task_context_switch_counts(struct task_struct *p, | ||
293 | char *buffer) | ||
294 | { | ||
295 | return buffer + sprintf(buffer, "voluntary_ctxt_switches:\t%lu\n" | ||
296 | "nonvoluntary_ctxt_switches:\t%lu\n", | ||
297 | p->nvcsw, | ||
298 | p->nivcsw); | ||
299 | } | ||
300 | |||
292 | int proc_pid_status(struct task_struct *task, char * buffer) | 301 | int proc_pid_status(struct task_struct *task, char * buffer) |
293 | { | 302 | { |
294 | char * orig = buffer; | 303 | char * orig = buffer; |
@@ -307,6 +316,7 @@ int proc_pid_status(struct task_struct *task, char * buffer) | |||
307 | #if defined(CONFIG_S390) | 316 | #if defined(CONFIG_S390) |
308 | buffer = task_show_regs(task, buffer); | 317 | buffer = task_show_regs(task, buffer); |
309 | #endif | 318 | #endif |
319 | buffer = task_context_switch_counts(task, buffer); | ||
310 | return buffer - orig; | 320 | return buffer - orig; |
311 | } | 321 | } |
312 | 322 | ||