Commit | Line | Data |
---|---|---|
d6a3b247 MCC |
1 | ==================== |
2 | Scheduler Statistics | |
3 | ==================== | |
4 | ||
11b0bfa5 IM |
5 | Version 16 of schedstats changed the order of definitions within |
6 | 'enum cpu_idle_type', which changed the order of [CPU_MAX_IDLE_TYPES] | |
7 | columns in show_schedstat(). In particular the position of CPU_IDLE | |
8 | and __CPU_NOT_IDLE changed places. The size of the array is unchanged. | |
9 | ||
1e1dbb25 JM |
10 | Version 15 of schedstats dropped counters for some sched_yield: |
11 | yld_exp_empty, yld_act_empty and yld_both_empty. Otherwise, it is | |
12 | identical to version 14. | |
13 | ||
b762f3ff JD |
14 | Version 14 of schedstats includes support for sched_domains, which hit the |
15 | mainline kernel in 2.6.20 although it is identical to the stats from version | |
16 | 12 which was in the kernel from 2.6.13-2.6.19 (version 13 never saw a kernel | |
17 | release). Some counters make more sense to be per-runqueue; other to be | |
18 | per-domain. Note that domains (and their associated information) will only | |
19 | be pertinent and available on machines utilizing CONFIG_SMP. | |
20 | ||
21 | In version 14 of schedstat, there is at least one level of domain | |
1da177e4 LT |
22 | statistics for each cpu listed, and there may well be more than one |
23 | domain. Domains have no particular names in this implementation, but | |
24 | the highest numbered one typically arbitrates balancing across all the | |
25 | cpus on the machine, while domain0 is the most tightly focused domain, | |
26 | sometimes balancing only between pairs of cpus. At this time, there | |
27 | are no architectures which need more than three domain levels. The first | |
28 | field in the domain stats is a bit map indicating which cpus are affected | |
29 | by that domain. | |
30 | ||
31 | These fields are counters, and only increment. Programs which make use | |
32 | of these will need to start with a baseline observation and then calculate | |
33 | the change in the counters at each subsequent observation. A perl script | |
34 | which does this for many of the fields is available at | |
35 | ||
d41abfd7 | 36 | http://eaglet.pdxhosts.com/rick/linux/schedstat/ |
1da177e4 LT |
37 | |
38 | Note that any such script will necessarily be version-specific, as the main | |
39 | reason to change versions is changes in the output format. For those wishing | |
40 | to write their own scripts, the fields are described here. | |
41 | ||
42 | CPU statistics | |
43 | -------------- | |
1e1dbb25 | 44 | cpu<N> 1 2 3 4 5 6 7 8 9 |
1da177e4 | 45 | |
1e1dbb25 | 46 | First field is a sched_yield() statistic: |
d6a3b247 | 47 | |
1e1dbb25 | 48 | 1) # of times sched_yield() was called |
1da177e4 | 49 | |
b762f3ff | 50 | Next three are schedule() statistics: |
d6a3b247 | 51 | |
30fd049a RM |
52 | 2) This field is a legacy array expiration count field used in the O(1) |
53 | scheduler. We kept it for ABI compatibility, but it is always set to zero. | |
1e1dbb25 JM |
54 | 3) # of times schedule() was called |
55 | 4) # of times schedule() left the processor idle | |
1da177e4 | 56 | |
b762f3ff | 57 | Next two are try_to_wake_up() statistics: |
d6a3b247 | 58 | |
1e1dbb25 JM |
59 | 5) # of times try_to_wake_up() was called |
60 | 6) # of times try_to_wake_up() was called to wake up the local cpu | |
1da177e4 LT |
61 | |
62 | Next three are statistics describing scheduling latency: | |
d6a3b247 | 63 | |
ddb21d27 | 64 | 7) sum of all time spent running by tasks on this processor (in nanoseconds) |
1e1dbb25 | 65 | 8) sum of all time spent waiting to run by tasks on this processor (in |
ddb21d27 | 66 | nanoseconds) |
1e1dbb25 | 67 | 9) # of timeslices run on this cpu |
1da177e4 LT |
68 | |
69 | ||
70 | Domain statistics | |
71 | ----------------- | |
72 | One of these is produced per domain for each cpu described. (Note that if | |
73 | CONFIG_SMP is not defined, *no* domains are utilized and these lines | |
74 | will not appear in the output.) | |
75 | ||
b762f3ff | 76 | domain<N> <cpumask> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
1da177e4 LT |
77 | |
78 | The first field is a bit mask indicating what cpus this domain operates over. | |
79 | ||
4c3e509e | 80 | The next 24 are a variety of sched_balance_rq() statistics in grouped into types |
b762f3ff JD |
81 | of idleness (idle, busy, and newly idle): |
82 | ||
4c3e509e | 83 | 1) # of times in this domain sched_balance_rq() was called when the |
b762f3ff | 84 | cpu was idle |
4c3e509e | 85 | 2) # of times in this domain sched_balance_rq() checked but found |
b762f3ff | 86 | the load did not require balancing when the cpu was idle |
4c3e509e | 87 | 3) # of times in this domain sched_balance_rq() tried to move one or |
b762f3ff | 88 | more tasks and failed, when the cpu was idle |
d6a3b247 | 89 | 4) sum of imbalances discovered (if any) with each call to |
4c3e509e | 90 | sched_balance_rq() in this domain when the cpu was idle |
d6a3b247 | 91 | 5) # of times in this domain pull_task() was called when the cpu |
b762f3ff | 92 | was idle |
d6a3b247 | 93 | 6) # of times in this domain pull_task() was called even though |
b762f3ff | 94 | the target task was cache-hot when idle |
4c3e509e | 95 | 7) # of times in this domain sched_balance_rq() was called but did |
b762f3ff | 96 | not find a busier queue while the cpu was idle |
d6a3b247 | 97 | 8) # of times in this domain a busier queue was found while the |
b762f3ff | 98 | cpu was idle but no busier group was found |
4c3e509e | 99 | 9) # of times in this domain sched_balance_rq() was called when the |
b762f3ff | 100 | cpu was busy |
4c3e509e | 101 | 10) # of times in this domain sched_balance_rq() checked but found the |
b762f3ff | 102 | load did not require balancing when busy |
4c3e509e | 103 | 11) # of times in this domain sched_balance_rq() tried to move one or |
b762f3ff JD |
104 | more tasks and failed, when the cpu was busy |
105 | 12) sum of imbalances discovered (if any) with each call to | |
4c3e509e | 106 | sched_balance_rq() in this domain when the cpu was busy |
b762f3ff JD |
107 | 13) # of times in this domain pull_task() was called when busy |
108 | 14) # of times in this domain pull_task() was called even though the | |
109 | target task was cache-hot when busy | |
4c3e509e | 110 | 15) # of times in this domain sched_balance_rq() was called but did not |
b762f3ff JD |
111 | find a busier queue while the cpu was busy |
112 | 16) # of times in this domain a busier queue was found while the cpu | |
113 | was busy but no busier group was found | |
114 | ||
4c3e509e | 115 | 17) # of times in this domain sched_balance_rq() was called when the |
b762f3ff | 116 | cpu was just becoming idle |
4c3e509e | 117 | 18) # of times in this domain sched_balance_rq() checked but found the |
b762f3ff | 118 | load did not require balancing when the cpu was just becoming idle |
4c3e509e | 119 | 19) # of times in this domain sched_balance_rq() tried to move one or more |
b762f3ff JD |
120 | tasks and failed, when the cpu was just becoming idle |
121 | 20) sum of imbalances discovered (if any) with each call to | |
4c3e509e | 122 | sched_balance_rq() in this domain when the cpu was just becoming idle |
b762f3ff JD |
123 | 21) # of times in this domain pull_task() was called when newly idle |
124 | 22) # of times in this domain pull_task() was called even though the | |
125 | target task was cache-hot when just becoming idle | |
4c3e509e | 126 | 23) # of times in this domain sched_balance_rq() was called but did not |
b762f3ff JD |
127 | find a busier queue while the cpu was just becoming idle |
128 | 24) # of times in this domain a busier queue was found while the cpu | |
129 | was just becoming idle but no busier group was found | |
130 | ||
131 | Next three are active_load_balance() statistics: | |
d6a3b247 | 132 | |
b762f3ff JD |
133 | 25) # of times active_load_balance() was called |
134 | 26) # of times active_load_balance() tried to move a task and failed | |
135 | 27) # of times active_load_balance() successfully moved a task | |
136 | ||
137 | Next three are sched_balance_exec() statistics: | |
d6a3b247 | 138 | |
b762f3ff JD |
139 | 28) sbe_cnt is not used |
140 | 29) sbe_balanced is not used | |
141 | 30) sbe_pushed is not used | |
142 | ||
143 | Next three are sched_balance_fork() statistics: | |
d6a3b247 | 144 | |
b762f3ff JD |
145 | 31) sbf_cnt is not used |
146 | 32) sbf_balanced is not used | |
147 | 33) sbf_pushed is not used | |
148 | ||
149 | Next three are try_to_wake_up() statistics: | |
d6a3b247 | 150 | |
b762f3ff JD |
151 | 34) # of times in this domain try_to_wake_up() awoke a task that |
152 | last ran on a different cpu in this domain | |
153 | 35) # of times in this domain try_to_wake_up() moved a task to the | |
154 | waking cpu because it was cache-cold on its own cpu anyway | |
155 | 36) # of times in this domain try_to_wake_up() started passive balancing | |
1da177e4 LT |
156 | |
157 | /proc/<pid>/schedstat | |
d6a3b247 | 158 | --------------------- |
9afa802f | 159 | schedstats also adds a new /proc/<pid>/schedstat file to include some of |
1da177e4 | 160 | the same information on a per-process level. There are three fields in |
b762f3ff | 161 | this file correlating for that process to: |
d6a3b247 | 162 | |
6c757e9f JTH |
163 | 1) time spent on the cpu (in nanoseconds) |
164 | 2) time spent waiting on a runqueue (in nanoseconds) | |
b762f3ff | 165 | 3) # of timeslices run on this cpu |
1da177e4 LT |
166 | |
167 | A program could be easily written to make use of these extra fields to | |
168 | report on how well a particular process or set of processes is faring | |
169 | under the scheduler's policies. A simple version of such a program is | |
170 | available at | |
d6a3b247 | 171 | |
d41abfd7 | 172 | http://eaglet.pdxhosts.com/rick/linux/schedstat/v12/latency.c |