aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/accounting/taskstats.txt
diff options
context:
space:
mode:
authorShailabh Nagar <nagar@watson.ibm.com>2006-07-14 03:24:44 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-15 00:53:57 -0400
commitad4ecbcba72855a2b5319b96e2a3a65ed1ca3bfd (patch)
treea2f5b98598948525de77ab594e4432f09a230388 /Documentation/accounting/taskstats.txt
parent25890454667b3295f67b3372352be90705f8667c (diff)
[PATCH] delay accounting taskstats interface send tgid once
Send per-tgid data only once during exit of a thread group instead of once with each member thread exit. Currently, when a thread exits, besides its per-tid data, the per-tgid data of its thread group is also sent out, if its thread group is non-empty. The per-tgid data sent consists of the sum of per-tid stats for all *remaining* threads of the thread group. This patch modifies this sending in two ways: - the per-tgid data is sent only when the last thread of a thread group exits. This cuts down heavily on the overhead of sending/receiving per-tgid data, especially when other exploiters of the taskstats interface aren't interested in per-tgid stats - the semantics of the per-tgid data sent are changed. Instead of being the sum of per-tid data for remaining threads, the value now sent is the true total accumalated statistics for all threads that are/were part of the thread group. The patch also addresses a minor issue where failure of one accounting subsystem to fill in the taskstats structure was causing the send of taskstats to not be sent at all. The patch has been tested for stability and run cerberus for over 4 hours on an SMP. [akpm@osdl.org: bugfixes] Signed-off-by: Shailabh Nagar <nagar@watson.ibm.com> Signed-off-by: Balbir Singh <balbir@in.ibm.com> Cc: Jay Lan <jlan@engr.sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'Documentation/accounting/taskstats.txt')
-rw-r--r--Documentation/accounting/taskstats.txt33
1 files changed, 13 insertions, 20 deletions
diff --git a/Documentation/accounting/taskstats.txt b/Documentation/accounting/taskstats.txt
index acc6b4f37fc7..efd8f605bcd5 100644
--- a/Documentation/accounting/taskstats.txt
+++ b/Documentation/accounting/taskstats.txt
@@ -32,12 +32,11 @@ The response contains statistics for a task (if pid is specified) or the sum of
32statistics for all tasks of the process (if tgid is specified). 32statistics for all tasks of the process (if tgid is specified).
33 33
34To obtain statistics for tasks which are exiting, userspace opens a multicast 34To obtain statistics for tasks which are exiting, userspace opens a multicast
35netlink socket. Each time a task exits, two records are sent by the kernel to 35netlink socket. Each time a task exits, its per-pid statistics is always sent
36each listener on the multicast socket. The first the per-pid task's statistics 36by the kernel to each listener on the multicast socket. In addition, if it is
37and the second is the sum for all tasks of the process to which the task 37the last thread exiting its thread group, an additional record containing the
38belongs (the task does not need to be the thread group leader). The need for 38per-tgid stats are also sent. The latter contains the sum of per-pid stats for
39per-tgid stats to be sent for each exiting task is explained in the per-tgid 39all threads in the thread group, both past and present.
40stats section below.
41 40
42getdelays.c is a simple utility demonstrating usage of the taskstats interface 41getdelays.c is a simple utility demonstrating usage of the taskstats interface
43for reporting delay accounting statistics. 42for reporting delay accounting statistics.
@@ -104,20 +103,14 @@ stats in userspace alone is inefficient and potentially inaccurate (due to lack
104of atomicity). 103of atomicity).
105 104
106However, maintaining per-process, in addition to per-task stats, within the 105However, maintaining per-process, in addition to per-task stats, within the
107kernel has space and time overheads. Hence the taskstats implementation 106kernel has space and time overheads. To address this, the taskstats code
108dynamically sums up the per-task stats for each task belonging to a process 107accumalates each exiting task's statistics into a process-wide data structure.
109whenever per-process stats are needed. 108When the last task of a process exits, the process level data accumalated also
110 109gets sent to userspace (along with the per-task data).
111Not maintaining per-tgid stats creates a problem when userspace is interested 110
112in getting these stats when the process dies i.e. the last thread of 111When a user queries to get per-tgid data, the sum of all other live threads in
113a process exits. It isn't possible to simply return some aggregated per-process 112the group is added up and added to the accumalated total for previously exited
114statistic from the kernel. 113threads of the same thread group.
115
116The approach taken by taskstats is to return the per-tgid stats *each* time
117a task exits, in addition to the per-pid stats for that task. Userspace can
118maintain task<->process mappings and use them to maintain the per-process stats
119in userspace, updating the aggregate appropriately as the tasks of a process
120exit.
121 114
122Extending taskstats 115Extending taskstats
123------------------- 116-------------------