aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/accounting/delay-accounting.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/accounting/delay-accounting.txt')
-rw-r--r--Documentation/accounting/delay-accounting.txt110
1 files changed, 110 insertions, 0 deletions
diff --git a/Documentation/accounting/delay-accounting.txt b/Documentation/accounting/delay-accounting.txt
new file mode 100644
index 000000000000..be215e58423b
--- /dev/null
+++ b/Documentation/accounting/delay-accounting.txt
@@ -0,0 +1,110 @@
1Delay accounting
2----------------
3
4Tasks encounter delays in execution when they wait
5for some kernel resource to become available e.g. a
6runnable task may wait for a free CPU to run on.
7
8The per-task delay accounting functionality measures
9the delays experienced by a task while
10
11a) waiting for a CPU (while being runnable)
12b) completion of synchronous block I/O initiated by the task
13c) swapping in pages
14
15and makes these statistics available to userspace through
16the taskstats interface.
17
18Such delays provide feedback for setting a task's cpu priority,
19io priority and rss limit values appropriately. Long delays for
20important tasks could be a trigger for raising its corresponding priority.
21
22The functionality, through its use of the taskstats interface, also provides
23delay statistics aggregated for all tasks (or threads) belonging to a
24thread group (corresponding to a traditional Unix process). This is a commonly
25needed aggregation that is more efficiently done by the kernel.
26
27Userspace utilities, particularly resource management applications, can also
28aggregate delay statistics into arbitrary groups. To enable this, delay
29statistics of a task are available both during its lifetime as well as on its
30exit, ensuring continuous and complete monitoring can be done.
31
32
33Interface
34---------
35
36Delay accounting uses the taskstats interface which is described
37in detail in a separate document in this directory. Taskstats returns a
38generic data structure to userspace corresponding to per-pid and per-tgid
39statistics. The delay accounting functionality populates specific fields of
40this structure. See
41 include/linux/taskstats.h
42for a description of the fields pertaining to delay accounting.
43It will generally be in the form of counters returning the cumulative
44delay seen for cpu, sync block I/O, swapin etc.
45
46Taking the difference of two successive readings of a given
47counter (say cpu_delay_total) for a task will give the delay
48experienced by the task waiting for the corresponding resource
49in that interval.
50
51When a task exits, records containing the per-task statistics
52are sent to userspace without requiring a command. If it is the last exiting
53task of a thread group, the per-tgid statistics are also sent. More details
54are given in the taskstats interface description.
55
56The getdelays.c userspace utility in this directory allows simple commands to
57be run and the corresponding delay statistics to be displayed. It also serves
58as an example of using the taskstats interface.
59
60Usage
61-----
62
63Compile the kernel with
64 CONFIG_TASK_DELAY_ACCT=y
65 CONFIG_TASKSTATS=y
66
67Enable the accounting at boot time by adding
68the following to the kernel boot options
69 delayacct
70
71and after the system has booted up, use a utility
72similar to getdelays.c to access the delays
73seen by a given task or a task group (tgid).
74The utility also allows a given command to be
75executed and the corresponding delays to be
76seen.
77
78General format of the getdelays command
79
80getdelays [-t tgid] [-p pid] [-c cmd...]
81
82
83Get delays, since system boot, for pid 10
84# ./getdelays -p 10
85(output similar to next case)
86
87Get sum of delays, since system boot, for all pids with tgid 5
88# ./getdelays -t 5
89
90
91CPU count real total virtual total delay total
92 7876 92005750 100000000 24001500
93IO count delay total
94 0 0
95MEM count delay total
96 0 0
97
98Get delays seen in executing a given simple command
99# ./getdelays -c ls /
100
101bin data1 data3 data5 dev home media opt root srv sys usr
102boot data2 data4 data6 etc lib mnt proc sbin subdomain tmp var
103
104
105CPU count real total virtual total delay total
106 6 4000250 4000000 0
107IO count delay total
108 0 0
109MEM count delay total
110 0 0