About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Documentation / accounting / delay-accounting.txt

Custom Search

Based on kernel version 4.13.3. Page generated on 2017-09-23 13:54 EST.

1	Delay accounting
2	----------------
4	Tasks encounter delays in execution when they wait
5	for some kernel resource to become available e.g. a
6	runnable task may wait for a free CPU to run on.
8	The per-task delay accounting functionality measures
9	the delays experienced by a task while
11	a) waiting for a CPU (while being runnable)
12	b) completion of synchronous block I/O initiated by the task
13	c) swapping in pages
14	d) memory reclaim
16	and makes these statistics available to userspace through
17	the taskstats interface.
19	Such delays provide feedback for setting a task's cpu priority,
20	io priority and rss limit values appropriately. Long delays for
21	important tasks could be a trigger for raising its corresponding priority.
23	The functionality, through its use of the taskstats interface, also provides
24	delay statistics aggregated for all tasks (or threads) belonging to a
25	thread group (corresponding to a traditional Unix process). This is a commonly
26	needed aggregation that is more efficiently done by the kernel.
28	Userspace utilities, particularly resource management applications, can also
29	aggregate delay statistics into arbitrary groups. To enable this, delay
30	statistics of a task are available both during its lifetime as well as on its
31	exit, ensuring continuous and complete monitoring can be done.
34	Interface
35	---------
37	Delay accounting uses the taskstats interface which is described
38	in detail in a separate document in this directory. Taskstats returns a
39	generic data structure to userspace corresponding to per-pid and per-tgid
40	statistics. The delay accounting functionality populates specific fields of
41	this structure. See
42	     include/linux/taskstats.h
43	for a description of the fields pertaining to delay accounting.
44	It will generally be in the form of counters returning the cumulative
45	delay seen for cpu, sync block I/O, swapin, memory reclaim etc.
47	Taking the difference of two successive readings of a given
48	counter (say cpu_delay_total) for a task will give the delay
49	experienced by the task waiting for the corresponding resource
50	in that interval.
52	When a task exits, records containing the per-task statistics
53	are sent to userspace without requiring a command. If it is the last exiting
54	task of a thread group, the per-tgid statistics are also sent. More details
55	are given in the taskstats interface description.
57	The getdelays.c userspace utility in tools/accounting directory allows simple
58	commands to be run and the corresponding delay statistics to be displayed. It
59	also serves as an example of using the taskstats interface.
61	Usage
62	-----
64	Compile the kernel with
68	Delay accounting is enabled by default at boot up.
69	To disable, add
70	   nodelayacct
71	to the kernel boot options. The rest of the instructions
72	below assume this has not been done.
74	After the system has booted up, use a utility
75	similar to  getdelays.c to access the delays
76	seen by a given task or a task group (tgid).
77	The utility also allows a given command to be
78	executed and the corresponding delays to be
79	seen.
81	General format of the getdelays command
83	getdelays [-t tgid] [-p pid] [-c cmd...]
86	Get delays, since system boot, for pid 10
87	# ./getdelays -p 10
88	(output similar to next case)
90	Get sum of delays, since system boot, for all pids with tgid 5
91	# ./getdelays -t 5
94	CPU	count	real total	virtual total	delay total
95		7876	92005750	100000000	24001500
96	IO	count	delay total
97		0	0
98	SWAP	count	delay total
99		0	0
100	RECLAIM	count	delay total
101		0	0
103	Get delays seen in executing a given simple command
104	# ./getdelays -c ls /
106	bin   data1  data3  data5  dev  home  media  opt   root  srv        sys  usr
107	boot  data2  data4  data6  etc  lib   mnt    proc  sbin  subdomain  tmp  var
110	CPU	count	real total	virtual total	delay total
111		6	4000250		4000000		0
112	IO	count	delay total
113		0	0
114	SWAP	count	delay total
115		0	0
116	RECLAIM	count	delay total
117		0	0
Hide Line Numbers
About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Information is copyright its respective author. All material is available from the Linux Kernel Source distributed under a GPL License. This page is provided as a free service by mjmwired.net.