If you have scripts for version 3, note that the only difference with version 4 is three new fields appended to the end. Version 3 scripts should need little or no porting since no previous fields have moved or changed meaning.
Format for version 4 of schedstat:
tag 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23tag is cpuN or totals.
NOTE: | In the sched_yield() statistics, the active queue is considered empty if it has only one process in it, since obviously the process calling sched_yield() is that process. |
First four are sched_yield() statistics:
Next four are schedule() statistics:
Next seven are statistics dealing with load_balance() (requires CONFIG_SMP):
Next four are statistics dealing with pull_task() (requires CONFIG_SMP):
Next two are statistics dealing with balance_node() (requires CONFIG_SMP and CONFIG_NUMA):
Last three are statistics dealing with scheduling latency:
The last three make it possible to find the average latency on a particular runqueue or the system overall. Given two points in time, A and B, (22B - 22A)/(23B - 23A) will give you the average time processes had to wait after being scheduled to run but before actually running.
This version of the patch also patches the stat output of individual processes to include the same information (obtainable from /proc/<pid>/stat). There, the above three new fields are tacked on the end but apply only for that process. The program latency.c, mentioned on the previous page, makes use of these extra fields to report on how well a particular process is faring under the scheduler's policies. The example below utilizes that program on a particular process, rather than examining runqueue statistics through sampling /proc/schedstat. The program observed, loadtest, is a simply-written cpu-intensive program and thus uses up most of its allocated timeslice without voluntarily pausing for I/O. Processes such as cc and bash may well pause for other I/O events and give up the cpu at times, and thus appear to have much smaller timeslices. But it is important to remember that avgrun only tells us, on average, how long we were on the cpu each time, not what our given timeslice was.
% latency 25611 25611 (loadtest) avgrun=60.36ms avgwait=0.00ms 25611 (loadtest) avgrun=92.56ms avgwait=0.00ms 25611 (loadtest) avgrun=99.94ms avgwait=0.00ms 25611 (loadtest) avgrun=99.94ms avgwait=0.00ms 25611 (loadtest) avgrun=99.94ms avgwait=0.00ms 25611 (loadtest) avgrun=99.96ms avgwait=0.00ms 25611 (loadtest) avgrun=99.96ms avgwait=0.00ms 25611 (loadtest) avgrun=99.94ms avgwait=0.02ms 25611 (loadtest) avgrun=99.94ms avgwait=0.00ms 25611 (loadtest) avgrun=99.94ms avgwait=0.00ms 25611 (loadtest) avgrun=99.94ms avgwait=0.00ms 25611 (loadtest) avgrun=99.94ms avgwait=0.00ms 25611 (loadtest) avgrun=99.94ms avgwait=0.00ms 25611 (loadtest) avgrun=99.92ms avgwait=0.02ms 25611 (loadtest) avgrun=99.96ms avgwait=0.00ms Process 25611 (loadtest) has exited. %