⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delay-accounting.txt

📁 linux 内核源代码
💻 TXT
字号:
Delay accounting----------------Tasks encounter delays in execution when they waitfor some kernel resource to become available e.g. arunnable task may wait for a free CPU to run on.The per-task delay accounting functionality measuresthe delays experienced by a task whilea) waiting for a CPU (while being runnable)b) completion of synchronous block I/O initiated by the taskc) swapping in pagesand makes these statistics available to userspace throughthe taskstats interface.Such delays provide feedback for setting a task's cpu priority,io priority and rss limit values appropriately. Long delays forimportant tasks could be a trigger for raising its corresponding priority.The functionality, through its use of the taskstats interface, also providesdelay statistics aggregated for all tasks (or threads) belonging to athread group (corresponding to a traditional Unix process). This is a commonlyneeded aggregation that is more efficiently done by the kernel.Userspace utilities, particularly resource management applications, can alsoaggregate delay statistics into arbitrary groups. To enable this, delaystatistics of a task are available both during its lifetime as well as on itsexit, ensuring continuous and complete monitoring can be done.Interface---------Delay accounting uses the taskstats interface which is describedin detail in a separate document in this directory. Taskstats returns ageneric data structure to userspace corresponding to per-pid and per-tgidstatistics. The delay accounting functionality populates specific fields ofthis structure. See     include/linux/taskstats.hfor a description of the fields pertaining to delay accounting.It will generally be in the form of counters returning the cumulativedelay seen for cpu, sync block I/O, swapin etc.Taking the difference of two successive readings of a givencounter (say cpu_delay_total) for a task will give the delayexperienced by the task waiting for the corresponding resourcein that interval.When a task exits, records containing the per-task statisticsare sent to userspace without requiring a command. If it is the last exitingtask of a thread group, the per-tgid statistics are also sent. More detailsare given in the taskstats interface description.The getdelays.c userspace utility in this directory allows simple commands tobe run and the corresponding delay statistics to be displayed. It also servesas an example of using the taskstats interface.Usage-----Compile the kernel with	CONFIG_TASK_DELAY_ACCT=y	CONFIG_TASKSTATS=yDelay accounting is enabled by default at boot up.To disable, add   nodelayacctto the kernel boot options. The rest of the instructionsbelow assume this has not been done.After the system has booted up, use a utilitysimilar to  getdelays.c to access the delaysseen by a given task or a task group (tgid).The utility also allows a given command to beexecuted and the corresponding delays to beseen.General format of the getdelays commandgetdelays [-t tgid] [-p pid] [-c cmd...]Get delays, since system boot, for pid 10# ./getdelays -p 10(output similar to next case)Get sum of delays, since system boot, for all pids with tgid 5# ./getdelays -t 5CPU	count	real total	virtual total	delay total	7876	92005750	100000000	24001500IO	count	delay total	0	0MEM	count	delay total	0	0Get delays seen in executing a given simple command# ./getdelays -c ls /bin   data1  data3  data5  dev  home  media  opt   root  srv        sys  usrboot  data2  data4  data6  etc  lib   mnt    proc  sbin  subdomain  tmp  varCPU	count	real total	virtual total	delay total	6	4000250		4000000		0IO	count	delay total	0	0MEM	count	delay total	0	0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -