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>
This commit is contained in:
committed by
Linus Torvalds
parent
a6c15c2b0f
commit
b663a79c19
@@ -196,6 +196,8 @@ static int fill_pid(pid_t pid, struct task_struct *tsk,
|
||||
|
||||
/* fill in basic acct fields */
|
||||
stats->version = TASKSTATS_VERSION;
|
||||
stats->nvcsw = tsk->nvcsw;
|
||||
stats->nivcsw = tsk->nivcsw;
|
||||
bacct_add_tsk(stats, tsk);
|
||||
|
||||
/* fill in extended acct fields */
|
||||
@@ -242,6 +244,8 @@ static int fill_tgid(pid_t tgid, struct task_struct *first,
|
||||
*/
|
||||
delayacct_add_tsk(stats, tsk);
|
||||
|
||||
stats->nvcsw += tsk->nvcsw;
|
||||
stats->nivcsw += tsk->nivcsw;
|
||||
} while_each_thread(first, tsk);
|
||||
|
||||
unlock_task_sighand(first, &flags);
|
||||
|
Reference in New Issue
Block a user