If you have scripts for version 4, note that several fields were deleted, causing other fields to move, and some new fields were added. Version 4 scripts should require a moderate porting effort, depending on how modular you made the field parsing.
Format for version 5 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 23 24tag 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 two are statistics dealing with pull_task() (requires CONFIG_SMP):
Next three are statistics dealing with active_load_balance() (requires CONFIG_SMP):
Next two are simply call counters for two routines:
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, (23B - 23A)/(24B - 24A) will give you the average time processes had to wait after being scheduled to run but before actually running.
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. %