Commit | Line | Data |
---|---|---|
43ae34cb | 1 | /* |
391e43da | 2 | * kernel/sched/debug.c |
43ae34cb | 3 | * |
325ea10c | 4 | * Print the CFS rbtree and other debugging details |
43ae34cb IM |
5 | * |
6 | * Copyright(C) 2007, Red Hat, Inc., Ingo Molnar | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | */ | |
029632fb PZ |
12 | #include "sched.h" |
13 | ||
efe25c2c BR |
14 | static DEFINE_SPINLOCK(sched_debug_lock); |
15 | ||
43ae34cb IM |
16 | /* |
17 | * This allows printing both to /proc/sched_debug and | |
18 | * to the console | |
19 | */ | |
20 | #define SEQ_printf(m, x...) \ | |
21 | do { \ | |
22 | if (m) \ | |
23 | seq_printf(m, x); \ | |
24 | else \ | |
a8c024cd | 25 | pr_cont(x); \ |
43ae34cb IM |
26 | } while (0) |
27 | ||
ef83a571 IM |
28 | /* |
29 | * Ease the printing of nsec fields: | |
30 | */ | |
90b2628f | 31 | static long long nsec_high(unsigned long long nsec) |
ef83a571 | 32 | { |
90b2628f | 33 | if ((long long)nsec < 0) { |
ef83a571 IM |
34 | nsec = -nsec; |
35 | do_div(nsec, 1000000); | |
36 | return -nsec; | |
37 | } | |
38 | do_div(nsec, 1000000); | |
39 | ||
40 | return nsec; | |
41 | } | |
42 | ||
90b2628f | 43 | static unsigned long nsec_low(unsigned long long nsec) |
ef83a571 | 44 | { |
90b2628f | 45 | if ((long long)nsec < 0) |
ef83a571 IM |
46 | nsec = -nsec; |
47 | ||
48 | return do_div(nsec, 1000000); | |
49 | } | |
50 | ||
51 | #define SPLIT_NS(x) nsec_high(x), nsec_low(x) | |
52 | ||
d6ca41d7 SRRH |
53 | #define SCHED_FEAT(name, enabled) \ |
54 | #name , | |
55 | ||
56 | static const char * const sched_feat_names[] = { | |
57 | #include "features.h" | |
58 | }; | |
59 | ||
60 | #undef SCHED_FEAT | |
61 | ||
62 | static int sched_feat_show(struct seq_file *m, void *v) | |
63 | { | |
64 | int i; | |
65 | ||
66 | for (i = 0; i < __SCHED_FEAT_NR; i++) { | |
67 | if (!(sysctl_sched_features & (1UL << i))) | |
68 | seq_puts(m, "NO_"); | |
69 | seq_printf(m, "%s ", sched_feat_names[i]); | |
70 | } | |
71 | seq_puts(m, "\n"); | |
72 | ||
73 | return 0; | |
74 | } | |
75 | ||
76 | #ifdef HAVE_JUMP_LABEL | |
77 | ||
78 | #define jump_label_key__true STATIC_KEY_INIT_TRUE | |
79 | #define jump_label_key__false STATIC_KEY_INIT_FALSE | |
80 | ||
81 | #define SCHED_FEAT(name, enabled) \ | |
82 | jump_label_key__##enabled , | |
83 | ||
84 | struct static_key sched_feat_keys[__SCHED_FEAT_NR] = { | |
85 | #include "features.h" | |
86 | }; | |
87 | ||
88 | #undef SCHED_FEAT | |
89 | ||
90 | static void sched_feat_disable(int i) | |
91 | { | |
92 | static_key_disable(&sched_feat_keys[i]); | |
93 | } | |
94 | ||
95 | static void sched_feat_enable(int i) | |
96 | { | |
97 | static_key_enable(&sched_feat_keys[i]); | |
98 | } | |
99 | #else | |
100 | static void sched_feat_disable(int i) { }; | |
101 | static void sched_feat_enable(int i) { }; | |
102 | #endif /* HAVE_JUMP_LABEL */ | |
103 | ||
104 | static int sched_feat_set(char *cmp) | |
105 | { | |
106 | int i; | |
107 | int neg = 0; | |
108 | ||
109 | if (strncmp(cmp, "NO_", 3) == 0) { | |
110 | neg = 1; | |
111 | cmp += 3; | |
112 | } | |
113 | ||
8f894bf4 YX |
114 | i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp); |
115 | if (i < 0) | |
116 | return i; | |
117 | ||
118 | if (neg) { | |
119 | sysctl_sched_features &= ~(1UL << i); | |
120 | sched_feat_disable(i); | |
121 | } else { | |
122 | sysctl_sched_features |= (1UL << i); | |
123 | sched_feat_enable(i); | |
d6ca41d7 SRRH |
124 | } |
125 | ||
8f894bf4 | 126 | return 0; |
d6ca41d7 SRRH |
127 | } |
128 | ||
129 | static ssize_t | |
130 | sched_feat_write(struct file *filp, const char __user *ubuf, | |
131 | size_t cnt, loff_t *ppos) | |
132 | { | |
133 | char buf[64]; | |
134 | char *cmp; | |
8f894bf4 | 135 | int ret; |
d6ca41d7 SRRH |
136 | struct inode *inode; |
137 | ||
138 | if (cnt > 63) | |
139 | cnt = 63; | |
140 | ||
141 | if (copy_from_user(&buf, ubuf, cnt)) | |
142 | return -EFAULT; | |
143 | ||
144 | buf[cnt] = 0; | |
145 | cmp = strstrip(buf); | |
146 | ||
147 | /* Ensure the static_key remains in a consistent state */ | |
148 | inode = file_inode(filp); | |
149 | inode_lock(inode); | |
8f894bf4 | 150 | ret = sched_feat_set(cmp); |
d6ca41d7 | 151 | inode_unlock(inode); |
8f894bf4 YX |
152 | if (ret < 0) |
153 | return ret; | |
d6ca41d7 SRRH |
154 | |
155 | *ppos += cnt; | |
156 | ||
157 | return cnt; | |
158 | } | |
159 | ||
160 | static int sched_feat_open(struct inode *inode, struct file *filp) | |
161 | { | |
162 | return single_open(filp, sched_feat_show, NULL); | |
163 | } | |
164 | ||
165 | static const struct file_operations sched_feat_fops = { | |
166 | .open = sched_feat_open, | |
167 | .write = sched_feat_write, | |
168 | .read = seq_read, | |
169 | .llseek = seq_lseek, | |
170 | .release = single_release, | |
171 | }; | |
172 | ||
9469eb01 PZ |
173 | __read_mostly bool sched_debug_enabled; |
174 | ||
d6ca41d7 SRRH |
175 | static __init int sched_init_debug(void) |
176 | { | |
177 | debugfs_create_file("sched_features", 0644, NULL, NULL, | |
178 | &sched_feat_fops); | |
179 | ||
9469eb01 PZ |
180 | debugfs_create_bool("sched_debug", 0644, NULL, |
181 | &sched_debug_enabled); | |
182 | ||
d6ca41d7 SRRH |
183 | return 0; |
184 | } | |
185 | late_initcall(sched_init_debug); | |
186 | ||
3866e845 SRRH |
187 | #ifdef CONFIG_SMP |
188 | ||
189 | #ifdef CONFIG_SYSCTL | |
190 | ||
191 | static struct ctl_table sd_ctl_dir[] = { | |
192 | { | |
193 | .procname = "sched_domain", | |
194 | .mode = 0555, | |
195 | }, | |
196 | {} | |
197 | }; | |
198 | ||
199 | static struct ctl_table sd_ctl_root[] = { | |
200 | { | |
201 | .procname = "kernel", | |
202 | .mode = 0555, | |
203 | .child = sd_ctl_dir, | |
204 | }, | |
205 | {} | |
206 | }; | |
207 | ||
208 | static struct ctl_table *sd_alloc_ctl_entry(int n) | |
209 | { | |
210 | struct ctl_table *entry = | |
211 | kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL); | |
212 | ||
213 | return entry; | |
214 | } | |
215 | ||
216 | static void sd_free_ctl_entry(struct ctl_table **tablep) | |
217 | { | |
218 | struct ctl_table *entry; | |
219 | ||
220 | /* | |
221 | * In the intermediate directories, both the child directory and | |
222 | * procname are dynamically allocated and could fail but the mode | |
223 | * will always be set. In the lowest directory the names are | |
224 | * static strings and all have proc handlers. | |
225 | */ | |
226 | for (entry = *tablep; entry->mode; entry++) { | |
227 | if (entry->child) | |
228 | sd_free_ctl_entry(&entry->child); | |
229 | if (entry->proc_handler == NULL) | |
230 | kfree(entry->procname); | |
231 | } | |
232 | ||
233 | kfree(*tablep); | |
234 | *tablep = NULL; | |
235 | } | |
236 | ||
237 | static int min_load_idx = 0; | |
238 | static int max_load_idx = CPU_LOAD_IDX_MAX-1; | |
239 | ||
240 | static void | |
241 | set_table_entry(struct ctl_table *entry, | |
242 | const char *procname, void *data, int maxlen, | |
243 | umode_t mode, proc_handler *proc_handler, | |
244 | bool load_idx) | |
245 | { | |
246 | entry->procname = procname; | |
247 | entry->data = data; | |
248 | entry->maxlen = maxlen; | |
249 | entry->mode = mode; | |
250 | entry->proc_handler = proc_handler; | |
251 | ||
252 | if (load_idx) { | |
253 | entry->extra1 = &min_load_idx; | |
254 | entry->extra2 = &max_load_idx; | |
255 | } | |
256 | } | |
257 | ||
258 | static struct ctl_table * | |
259 | sd_alloc_ctl_domain_table(struct sched_domain *sd) | |
260 | { | |
261 | struct ctl_table *table = sd_alloc_ctl_entry(14); | |
262 | ||
263 | if (table == NULL) | |
264 | return NULL; | |
265 | ||
97fb7a0a IM |
266 | set_table_entry(&table[0] , "min_interval", &sd->min_interval, sizeof(long), 0644, proc_doulongvec_minmax, false); |
267 | set_table_entry(&table[1] , "max_interval", &sd->max_interval, sizeof(long), 0644, proc_doulongvec_minmax, false); | |
268 | set_table_entry(&table[2] , "busy_idx", &sd->busy_idx, sizeof(int) , 0644, proc_dointvec_minmax, true ); | |
269 | set_table_entry(&table[3] , "idle_idx", &sd->idle_idx, sizeof(int) , 0644, proc_dointvec_minmax, true ); | |
270 | set_table_entry(&table[4] , "newidle_idx", &sd->newidle_idx, sizeof(int) , 0644, proc_dointvec_minmax, true ); | |
271 | set_table_entry(&table[5] , "wake_idx", &sd->wake_idx, sizeof(int) , 0644, proc_dointvec_minmax, true ); | |
272 | set_table_entry(&table[6] , "forkexec_idx", &sd->forkexec_idx, sizeof(int) , 0644, proc_dointvec_minmax, true ); | |
273 | set_table_entry(&table[7] , "busy_factor", &sd->busy_factor, sizeof(int) , 0644, proc_dointvec_minmax, false); | |
274 | set_table_entry(&table[8] , "imbalance_pct", &sd->imbalance_pct, sizeof(int) , 0644, proc_dointvec_minmax, false); | |
275 | set_table_entry(&table[9] , "cache_nice_tries", &sd->cache_nice_tries, sizeof(int) , 0644, proc_dointvec_minmax, false); | |
276 | set_table_entry(&table[10], "flags", &sd->flags, sizeof(int) , 0644, proc_dointvec_minmax, false); | |
277 | set_table_entry(&table[11], "max_newidle_lb_cost", &sd->max_newidle_lb_cost, sizeof(long), 0644, proc_doulongvec_minmax, false); | |
278 | set_table_entry(&table[12], "name", sd->name, CORENAME_MAX_SIZE, 0444, proc_dostring, false); | |
3866e845 SRRH |
279 | /* &table[13] is terminator */ |
280 | ||
281 | return table; | |
282 | } | |
283 | ||
284 | static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu) | |
285 | { | |
286 | struct ctl_table *entry, *table; | |
287 | struct sched_domain *sd; | |
288 | int domain_num = 0, i; | |
289 | char buf[32]; | |
290 | ||
291 | for_each_domain(cpu, sd) | |
292 | domain_num++; | |
293 | entry = table = sd_alloc_ctl_entry(domain_num + 1); | |
294 | if (table == NULL) | |
295 | return NULL; | |
296 | ||
297 | i = 0; | |
298 | for_each_domain(cpu, sd) { | |
299 | snprintf(buf, 32, "domain%d", i); | |
300 | entry->procname = kstrdup(buf, GFP_KERNEL); | |
301 | entry->mode = 0555; | |
302 | entry->child = sd_alloc_ctl_domain_table(sd); | |
303 | entry++; | |
304 | i++; | |
305 | } | |
306 | return table; | |
307 | } | |
308 | ||
97fb7a0a IM |
309 | static cpumask_var_t sd_sysctl_cpus; |
310 | static struct ctl_table_header *sd_sysctl_header; | |
bbdacdfe | 311 | |
3866e845 SRRH |
312 | void register_sched_domain_sysctl(void) |
313 | { | |
bbdacdfe PZ |
314 | static struct ctl_table *cpu_entries; |
315 | static struct ctl_table **cpu_idx; | |
3866e845 | 316 | char buf[32]; |
bbdacdfe | 317 | int i; |
3866e845 | 318 | |
bbdacdfe PZ |
319 | if (!cpu_entries) { |
320 | cpu_entries = sd_alloc_ctl_entry(num_possible_cpus() + 1); | |
321 | if (!cpu_entries) | |
322 | return; | |
3866e845 | 323 | |
bbdacdfe PZ |
324 | WARN_ON(sd_ctl_dir[0].child); |
325 | sd_ctl_dir[0].child = cpu_entries; | |
326 | } | |
3866e845 | 327 | |
bbdacdfe PZ |
328 | if (!cpu_idx) { |
329 | struct ctl_table *e = cpu_entries; | |
330 | ||
331 | cpu_idx = kcalloc(nr_cpu_ids, sizeof(struct ctl_table*), GFP_KERNEL); | |
332 | if (!cpu_idx) | |
333 | return; | |
334 | ||
335 | /* deal with sparse possible map */ | |
336 | for_each_possible_cpu(i) { | |
337 | cpu_idx[i] = e; | |
338 | e++; | |
339 | } | |
340 | } | |
341 | ||
342 | if (!cpumask_available(sd_sysctl_cpus)) { | |
343 | if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL)) | |
344 | return; | |
345 | ||
346 | /* init to possible to not have holes in @cpu_entries */ | |
347 | cpumask_copy(sd_sysctl_cpus, cpu_possible_mask); | |
348 | } | |
349 | ||
350 | for_each_cpu(i, sd_sysctl_cpus) { | |
351 | struct ctl_table *e = cpu_idx[i]; | |
352 | ||
353 | if (e->child) | |
354 | sd_free_ctl_entry(&e->child); | |
355 | ||
356 | if (!e->procname) { | |
357 | snprintf(buf, 32, "cpu%d", i); | |
358 | e->procname = kstrdup(buf, GFP_KERNEL); | |
359 | } | |
360 | e->mode = 0555; | |
361 | e->child = sd_alloc_ctl_cpu_table(i); | |
362 | ||
363 | __cpumask_clear_cpu(i, sd_sysctl_cpus); | |
3866e845 SRRH |
364 | } |
365 | ||
366 | WARN_ON(sd_sysctl_header); | |
367 | sd_sysctl_header = register_sysctl_table(sd_ctl_root); | |
368 | } | |
369 | ||
bbdacdfe PZ |
370 | void dirty_sched_domain_sysctl(int cpu) |
371 | { | |
372 | if (cpumask_available(sd_sysctl_cpus)) | |
373 | __cpumask_set_cpu(cpu, sd_sysctl_cpus); | |
374 | } | |
375 | ||
3866e845 SRRH |
376 | /* may be called multiple times per register */ |
377 | void unregister_sched_domain_sysctl(void) | |
378 | { | |
379 | unregister_sysctl_table(sd_sysctl_header); | |
380 | sd_sysctl_header = NULL; | |
3866e845 SRRH |
381 | } |
382 | #endif /* CONFIG_SYSCTL */ | |
383 | #endif /* CONFIG_SMP */ | |
384 | ||
ff9b48c3 | 385 | #ifdef CONFIG_FAIR_GROUP_SCHED |
5091faa4 | 386 | static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg) |
ff9b48c3 BR |
387 | { |
388 | struct sched_entity *se = tg->se[cpu]; | |
ff9b48c3 | 389 | |
97fb7a0a IM |
390 | #define P(F) SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)F) |
391 | #define P_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)schedstat_val(F)) | |
392 | #define PN(F) SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)F)) | |
393 | #define PN_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)schedstat_val(F))) | |
ff9b48c3 | 394 | |
cd126afe | 395 | if (!se) |
18bf2805 | 396 | return; |
18bf2805 | 397 | |
ff9b48c3 BR |
398 | PN(se->exec_start); |
399 | PN(se->vruntime); | |
400 | PN(se->sum_exec_runtime); | |
97fb7a0a | 401 | |
cb251765 | 402 | if (schedstat_enabled()) { |
4fa8d299 JP |
403 | PN_SCHEDSTAT(se->statistics.wait_start); |
404 | PN_SCHEDSTAT(se->statistics.sleep_start); | |
405 | PN_SCHEDSTAT(se->statistics.block_start); | |
406 | PN_SCHEDSTAT(se->statistics.sleep_max); | |
407 | PN_SCHEDSTAT(se->statistics.block_max); | |
408 | PN_SCHEDSTAT(se->statistics.exec_max); | |
409 | PN_SCHEDSTAT(se->statistics.slice_max); | |
410 | PN_SCHEDSTAT(se->statistics.wait_max); | |
411 | PN_SCHEDSTAT(se->statistics.wait_sum); | |
412 | P_SCHEDSTAT(se->statistics.wait_count); | |
cb251765 | 413 | } |
97fb7a0a | 414 | |
ff9b48c3 | 415 | P(se->load.weight); |
1ea6c46a | 416 | P(se->runnable_weight); |
9d85f21c | 417 | #ifdef CONFIG_SMP |
9d89c257 YD |
418 | P(se->avg.load_avg); |
419 | P(se->avg.util_avg); | |
1ea6c46a | 420 | P(se->avg.runnable_load_avg); |
9d85f21c | 421 | #endif |
4fa8d299 JP |
422 | |
423 | #undef PN_SCHEDSTAT | |
ff9b48c3 | 424 | #undef PN |
4fa8d299 | 425 | #undef P_SCHEDSTAT |
ff9b48c3 BR |
426 | #undef P |
427 | } | |
428 | #endif | |
429 | ||
efe25c2c BR |
430 | #ifdef CONFIG_CGROUP_SCHED |
431 | static char group_path[PATH_MAX]; | |
432 | ||
433 | static char *task_group_path(struct task_group *tg) | |
434 | { | |
8ecedd7a BR |
435 | if (autogroup_path(tg, group_path, PATH_MAX)) |
436 | return group_path; | |
437 | ||
4c737b41 | 438 | cgroup_path(tg->css.cgroup, group_path, PATH_MAX); |
97fb7a0a | 439 | |
4c737b41 | 440 | return group_path; |
efe25c2c BR |
441 | } |
442 | #endif | |
443 | ||
43ae34cb | 444 | static void |
a48da48b | 445 | print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) |
43ae34cb | 446 | { |
20435d84 | 447 | if (rq->curr == p) |
e8c16495 | 448 | SEQ_printf(m, ">R"); |
20435d84 XX |
449 | else |
450 | SEQ_printf(m, " %c", task_state_to_char(p)); | |
43ae34cb | 451 | |
ef83a571 | 452 | SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ", |
fc840914 | 453 | p->comm, task_pid_nr(p), |
ef83a571 | 454 | SPLIT_NS(p->se.vruntime), |
43ae34cb | 455 | (long long)(p->nvcsw + p->nivcsw), |
6f605d83 | 456 | p->prio); |
9c572591 | 457 | |
33d6176e | 458 | SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld", |
20e1d486 | 459 | SPLIT_NS(schedstat_val_or_zero(p->se.statistics.wait_sum)), |
33d6176e | 460 | SPLIT_NS(p->se.sum_exec_runtime), |
20e1d486 | 461 | SPLIT_NS(schedstat_val_or_zero(p->se.statistics.sum_sleep_runtime))); |
9c572591 | 462 | |
b32e86b4 | 463 | #ifdef CONFIG_NUMA_BALANCING |
e3d24d0a | 464 | SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p)); |
b32e86b4 | 465 | #endif |
efe25c2c BR |
466 | #ifdef CONFIG_CGROUP_SCHED |
467 | SEQ_printf(m, " %s", task_group_path(task_group(p))); | |
468 | #endif | |
d19ca308 | 469 | |
d19ca308 | 470 | SEQ_printf(m, "\n"); |
43ae34cb IM |
471 | } |
472 | ||
a48da48b | 473 | static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu) |
43ae34cb IM |
474 | { |
475 | struct task_struct *g, *p; | |
476 | ||
e9ca2670 JL |
477 | SEQ_printf(m, "\n"); |
478 | SEQ_printf(m, "runnable tasks:\n"); | |
479 | SEQ_printf(m, " S task PID tree-key switches prio" | |
480 | " wait-time sum-exec sum-sleep\n"); | |
481 | SEQ_printf(m, "-------------------------------------------------------" | |
482 | "----------------------------------------------------\n"); | |
43ae34cb | 483 | |
5bd96ab6 | 484 | rcu_read_lock(); |
d38e83c7 | 485 | for_each_process_thread(g, p) { |
b32e86b4 | 486 | if (task_cpu(p) != rq_cpu) |
43ae34cb IM |
487 | continue; |
488 | ||
a48da48b | 489 | print_task(m, rq, p); |
d38e83c7 | 490 | } |
5bd96ab6 | 491 | rcu_read_unlock(); |
43ae34cb IM |
492 | } |
493 | ||
5cef9eca | 494 | void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) |
43ae34cb | 495 | { |
86d9560c IM |
496 | s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1, |
497 | spread, rq0_min_vruntime, spread0; | |
348ec61e | 498 | struct rq *rq = cpu_rq(cpu); |
67e12eac IM |
499 | struct sched_entity *last; |
500 | unsigned long flags; | |
501 | ||
efe25c2c | 502 | #ifdef CONFIG_FAIR_GROUP_SCHED |
e9ca2670 JL |
503 | SEQ_printf(m, "\n"); |
504 | SEQ_printf(m, "cfs_rq[%d]:%s\n", cpu, task_group_path(cfs_rq->tg)); | |
efe25c2c | 505 | #else |
e9ca2670 JL |
506 | SEQ_printf(m, "\n"); |
507 | SEQ_printf(m, "cfs_rq[%d]:\n", cpu); | |
efe25c2c | 508 | #endif |
ef83a571 IM |
509 | SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "exec_clock", |
510 | SPLIT_NS(cfs_rq->exec_clock)); | |
67e12eac | 511 | |
05fa785c | 512 | raw_spin_lock_irqsave(&rq->lock, flags); |
bfb06889 | 513 | if (rb_first_cached(&cfs_rq->tasks_timeline)) |
ac53db59 | 514 | MIN_vruntime = (__pick_first_entity(cfs_rq))->vruntime; |
67e12eac IM |
515 | last = __pick_last_entity(cfs_rq); |
516 | if (last) | |
517 | max_vruntime = last->vruntime; | |
5ac5c4d6 | 518 | min_vruntime = cfs_rq->min_vruntime; |
348ec61e | 519 | rq0_min_vruntime = cpu_rq(0)->cfs.min_vruntime; |
05fa785c | 520 | raw_spin_unlock_irqrestore(&rq->lock, flags); |
ef83a571 IM |
521 | SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "MIN_vruntime", |
522 | SPLIT_NS(MIN_vruntime)); | |
523 | SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "min_vruntime", | |
524 | SPLIT_NS(min_vruntime)); | |
525 | SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "max_vruntime", | |
526 | SPLIT_NS(max_vruntime)); | |
67e12eac | 527 | spread = max_vruntime - MIN_vruntime; |
ef83a571 IM |
528 | SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread", |
529 | SPLIT_NS(spread)); | |
86d9560c | 530 | spread0 = min_vruntime - rq0_min_vruntime; |
ef83a571 IM |
531 | SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread0", |
532 | SPLIT_NS(spread0)); | |
5ac5c4d6 | 533 | SEQ_printf(m, " .%-30s: %d\n", "nr_spread_over", |
ddc97297 | 534 | cfs_rq->nr_spread_over); |
c82513e5 | 535 | SEQ_printf(m, " .%-30s: %d\n", "nr_running", cfs_rq->nr_running); |
2069dd75 | 536 | SEQ_printf(m, " .%-30s: %ld\n", "load", cfs_rq->load.weight); |
c09595f6 | 537 | #ifdef CONFIG_SMP |
1ea6c46a | 538 | SEQ_printf(m, " .%-30s: %ld\n", "runnable_weight", cfs_rq->runnable_weight); |
9d89c257 YD |
539 | SEQ_printf(m, " .%-30s: %lu\n", "load_avg", |
540 | cfs_rq->avg.load_avg); | |
13962234 | 541 | SEQ_printf(m, " .%-30s: %lu\n", "runnable_load_avg", |
1ea6c46a | 542 | cfs_rq->avg.runnable_load_avg); |
9d89c257 YD |
543 | SEQ_printf(m, " .%-30s: %lu\n", "util_avg", |
544 | cfs_rq->avg.util_avg); | |
7f65ea42 PB |
545 | SEQ_printf(m, " .%-30s: %u\n", "util_est_enqueued", |
546 | cfs_rq->avg.util_est.enqueued); | |
2a2f5d4e PZ |
547 | SEQ_printf(m, " .%-30s: %ld\n", "removed.load_avg", |
548 | cfs_rq->removed.load_avg); | |
549 | SEQ_printf(m, " .%-30s: %ld\n", "removed.util_avg", | |
550 | cfs_rq->removed.util_avg); | |
0e2d2aaa PZ |
551 | SEQ_printf(m, " .%-30s: %ld\n", "removed.runnable_sum", |
552 | cfs_rq->removed.runnable_sum); | |
333bb864 | 553 | #ifdef CONFIG_FAIR_GROUP_SCHED |
9d89c257 YD |
554 | SEQ_printf(m, " .%-30s: %lu\n", "tg_load_avg_contrib", |
555 | cfs_rq->tg_load_avg_contrib); | |
333bb864 AS |
556 | SEQ_printf(m, " .%-30s: %ld\n", "tg_load_avg", |
557 | atomic_long_read(&cfs_rq->tg->load_avg)); | |
c09595f6 | 558 | #endif |
333bb864 | 559 | #endif |
f9f9ffc2 | 560 | #ifdef CONFIG_CFS_BANDWIDTH |
f9f9ffc2 BS |
561 | SEQ_printf(m, " .%-30s: %d\n", "throttled", |
562 | cfs_rq->throttled); | |
563 | SEQ_printf(m, " .%-30s: %d\n", "throttle_count", | |
564 | cfs_rq->throttle_count); | |
565 | #endif | |
2069dd75 | 566 | |
333bb864 | 567 | #ifdef CONFIG_FAIR_GROUP_SCHED |
ff9b48c3 | 568 | print_cfs_group_stats(m, cpu, cfs_rq->tg); |
c09595f6 | 569 | #endif |
43ae34cb IM |
570 | } |
571 | ||
ada18de2 PZ |
572 | void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq) |
573 | { | |
efe25c2c | 574 | #ifdef CONFIG_RT_GROUP_SCHED |
e9ca2670 JL |
575 | SEQ_printf(m, "\n"); |
576 | SEQ_printf(m, "rt_rq[%d]:%s\n", cpu, task_group_path(rt_rq->tg)); | |
efe25c2c | 577 | #else |
e9ca2670 JL |
578 | SEQ_printf(m, "\n"); |
579 | SEQ_printf(m, "rt_rq[%d]:\n", cpu); | |
efe25c2c | 580 | #endif |
ada18de2 PZ |
581 | |
582 | #define P(x) \ | |
583 | SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rt_rq->x)) | |
48365b38 DBO |
584 | #define PU(x) \ |
585 | SEQ_printf(m, " .%-30s: %lu\n", #x, (unsigned long)(rt_rq->x)) | |
ada18de2 PZ |
586 | #define PN(x) \ |
587 | SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rt_rq->x)) | |
588 | ||
48365b38 DBO |
589 | PU(rt_nr_running); |
590 | #ifdef CONFIG_SMP | |
591 | PU(rt_nr_migratory); | |
592 | #endif | |
ada18de2 PZ |
593 | P(rt_throttled); |
594 | PN(rt_time); | |
595 | PN(rt_runtime); | |
596 | ||
597 | #undef PN | |
48365b38 | 598 | #undef PU |
ada18de2 PZ |
599 | #undef P |
600 | } | |
601 | ||
acb32132 WL |
602 | void print_dl_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq) |
603 | { | |
ef477183 SRRH |
604 | struct dl_bw *dl_bw; |
605 | ||
e9ca2670 JL |
606 | SEQ_printf(m, "\n"); |
607 | SEQ_printf(m, "dl_rq[%d]:\n", cpu); | |
48365b38 DBO |
608 | |
609 | #define PU(x) \ | |
610 | SEQ_printf(m, " .%-30s: %lu\n", #x, (unsigned long)(dl_rq->x)) | |
611 | ||
612 | PU(dl_nr_running); | |
ef477183 | 613 | #ifdef CONFIG_SMP |
48365b38 | 614 | PU(dl_nr_migratory); |
ef477183 SRRH |
615 | dl_bw = &cpu_rq(cpu)->rd->dl_bw; |
616 | #else | |
617 | dl_bw = &dl_rq->dl_bw; | |
618 | #endif | |
619 | SEQ_printf(m, " .%-30s: %lld\n", "dl_bw->bw", dl_bw->bw); | |
620 | SEQ_printf(m, " .%-30s: %lld\n", "dl_bw->total_bw", dl_bw->total_bw); | |
48365b38 DBO |
621 | |
622 | #undef PU | |
acb32132 WL |
623 | } |
624 | ||
a48da48b | 625 | static void print_cpu(struct seq_file *m, int cpu) |
43ae34cb | 626 | { |
348ec61e | 627 | struct rq *rq = cpu_rq(cpu); |
efe25c2c | 628 | unsigned long flags; |
43ae34cb IM |
629 | |
630 | #ifdef CONFIG_X86 | |
631 | { | |
632 | unsigned int freq = cpu_khz ? : 1; | |
633 | ||
bbbfeac9 | 634 | SEQ_printf(m, "cpu#%d, %u.%03u MHz\n", |
43ae34cb IM |
635 | cpu, freq / 1000, (freq % 1000)); |
636 | } | |
637 | #else | |
bbbfeac9 | 638 | SEQ_printf(m, "cpu#%d\n", cpu); |
43ae34cb IM |
639 | #endif |
640 | ||
13e099d2 PZ |
641 | #define P(x) \ |
642 | do { \ | |
643 | if (sizeof(rq->x) == 4) \ | |
644 | SEQ_printf(m, " .%-30s: %ld\n", #x, (long)(rq->x)); \ | |
645 | else \ | |
646 | SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rq->x));\ | |
647 | } while (0) | |
648 | ||
ef83a571 IM |
649 | #define PN(x) \ |
650 | SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rq->x)) | |
43ae34cb IM |
651 | |
652 | P(nr_running); | |
653 | SEQ_printf(m, " .%-30s: %lu\n", "load", | |
495eca49 | 654 | rq->load.weight); |
43ae34cb IM |
655 | P(nr_switches); |
656 | P(nr_load_updates); | |
657 | P(nr_uninterruptible); | |
ef83a571 | 658 | PN(next_balance); |
fc840914 | 659 | SEQ_printf(m, " .%-30s: %ld\n", "curr->pid", (long)(task_pid_nr(rq->curr))); |
ef83a571 | 660 | PN(clock); |
5a537597 | 661 | PN(clock_task); |
43ae34cb IM |
662 | P(cpu_load[0]); |
663 | P(cpu_load[1]); | |
664 | P(cpu_load[2]); | |
665 | P(cpu_load[3]); | |
666 | P(cpu_load[4]); | |
667 | #undef P | |
ef83a571 | 668 | #undef PN |
43ae34cb | 669 | |
1b9508f6 | 670 | #ifdef CONFIG_SMP |
db6ea2fb | 671 | #define P64(n) SEQ_printf(m, " .%-30s: %Ld\n", #n, rq->n); |
1b9508f6 | 672 | P64(avg_idle); |
37e6bae8 | 673 | P64(max_idle_balance_cost); |
db6ea2fb | 674 | #undef P64 |
1b9508f6 | 675 | #endif |
5ac5c4d6 | 676 | |
4fa8d299 | 677 | #define P(n) SEQ_printf(m, " .%-30s: %d\n", #n, schedstat_val(rq->n)); |
cb251765 MG |
678 | if (schedstat_enabled()) { |
679 | P(yld_count); | |
680 | P(sched_count); | |
681 | P(sched_goidle); | |
682 | P(ttwu_count); | |
683 | P(ttwu_local); | |
684 | } | |
5ac5c4d6 | 685 | #undef P |
4fa8d299 | 686 | |
efe25c2c | 687 | spin_lock_irqsave(&sched_debug_lock, flags); |
5cef9eca | 688 | print_cfs_stats(m, cpu); |
ada18de2 | 689 | print_rt_stats(m, cpu); |
acb32132 | 690 | print_dl_stats(m, cpu); |
43ae34cb | 691 | |
a48da48b | 692 | print_rq(m, rq, cpu); |
efe25c2c | 693 | spin_unlock_irqrestore(&sched_debug_lock, flags); |
bbbfeac9 | 694 | SEQ_printf(m, "\n"); |
43ae34cb IM |
695 | } |
696 | ||
1983a922 CE |
697 | static const char *sched_tunable_scaling_names[] = { |
698 | "none", | |
699 | "logaritmic", | |
700 | "linear" | |
701 | }; | |
702 | ||
bbbfeac9 | 703 | static void sched_debug_header(struct seq_file *m) |
43ae34cb | 704 | { |
5bb6b1ea PZ |
705 | u64 ktime, sched_clk, cpu_clk; |
706 | unsigned long flags; | |
43ae34cb | 707 | |
5bb6b1ea PZ |
708 | local_irq_save(flags); |
709 | ktime = ktime_to_ns(ktime_get()); | |
710 | sched_clk = sched_clock(); | |
711 | cpu_clk = local_clock(); | |
712 | local_irq_restore(flags); | |
713 | ||
b32e86b4 | 714 | SEQ_printf(m, "Sched Debug Version: v0.11, %s %.*s\n", |
43ae34cb IM |
715 | init_utsname()->release, |
716 | (int)strcspn(init_utsname()->version, " "), | |
717 | init_utsname()->version); | |
718 | ||
5bb6b1ea PZ |
719 | #define P(x) \ |
720 | SEQ_printf(m, "%-40s: %Ld\n", #x, (long long)(x)) | |
721 | #define PN(x) \ | |
722 | SEQ_printf(m, "%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x)) | |
723 | PN(ktime); | |
724 | PN(sched_clk); | |
725 | PN(cpu_clk); | |
726 | P(jiffies); | |
727 | #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK | |
35af99e6 | 728 | P(sched_clock_stable()); |
5bb6b1ea PZ |
729 | #endif |
730 | #undef PN | |
731 | #undef P | |
732 | ||
733 | SEQ_printf(m, "\n"); | |
734 | SEQ_printf(m, "sysctl_sched\n"); | |
43ae34cb | 735 | |
1aa4731e | 736 | #define P(x) \ |
d822cece | 737 | SEQ_printf(m, " .%-40s: %Ld\n", #x, (long long)(x)) |
1aa4731e | 738 | #define PN(x) \ |
d822cece | 739 | SEQ_printf(m, " .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x)) |
1aa4731e | 740 | PN(sysctl_sched_latency); |
b2be5e96 | 741 | PN(sysctl_sched_min_granularity); |
1aa4731e | 742 | PN(sysctl_sched_wakeup_granularity); |
eebef746 | 743 | P(sysctl_sched_child_runs_first); |
1aa4731e IM |
744 | P(sysctl_sched_features); |
745 | #undef PN | |
746 | #undef P | |
747 | ||
bbbfeac9 NZ |
748 | SEQ_printf(m, " .%-40s: %d (%s)\n", |
749 | "sysctl_sched_tunable_scaling", | |
1983a922 CE |
750 | sysctl_sched_tunable_scaling, |
751 | sched_tunable_scaling_names[sysctl_sched_tunable_scaling]); | |
bbbfeac9 NZ |
752 | SEQ_printf(m, "\n"); |
753 | } | |
1983a922 | 754 | |
bbbfeac9 NZ |
755 | static int sched_debug_show(struct seq_file *m, void *v) |
756 | { | |
757 | int cpu = (unsigned long)(v - 2); | |
43ae34cb | 758 | |
bbbfeac9 NZ |
759 | if (cpu != -1) |
760 | print_cpu(m, cpu); | |
761 | else | |
762 | sched_debug_header(m); | |
43ae34cb IM |
763 | |
764 | return 0; | |
765 | } | |
766 | ||
029632fb | 767 | void sysrq_sched_debug_show(void) |
43ae34cb | 768 | { |
bbbfeac9 NZ |
769 | int cpu; |
770 | ||
771 | sched_debug_header(NULL); | |
772 | for_each_online_cpu(cpu) | |
773 | print_cpu(NULL, cpu); | |
774 | ||
775 | } | |
776 | ||
777 | /* | |
778 | * This itererator needs some explanation. | |
779 | * It returns 1 for the header position. | |
97fb7a0a IM |
780 | * This means 2 is CPU 0. |
781 | * In a hotplugged system some CPUs, including CPU 0, may be missing so we have | |
782 | * to use cpumask_* to iterate over the CPUs. | |
bbbfeac9 NZ |
783 | */ |
784 | static void *sched_debug_start(struct seq_file *file, loff_t *offset) | |
785 | { | |
786 | unsigned long n = *offset; | |
787 | ||
788 | if (n == 0) | |
789 | return (void *) 1; | |
790 | ||
791 | n--; | |
792 | ||
793 | if (n > 0) | |
794 | n = cpumask_next(n - 1, cpu_online_mask); | |
795 | else | |
796 | n = cpumask_first(cpu_online_mask); | |
797 | ||
798 | *offset = n + 1; | |
799 | ||
800 | if (n < nr_cpu_ids) | |
801 | return (void *)(unsigned long)(n + 2); | |
97fb7a0a | 802 | |
bbbfeac9 NZ |
803 | return NULL; |
804 | } | |
805 | ||
806 | static void *sched_debug_next(struct seq_file *file, void *data, loff_t *offset) | |
807 | { | |
808 | (*offset)++; | |
809 | return sched_debug_start(file, offset); | |
810 | } | |
811 | ||
812 | static void sched_debug_stop(struct seq_file *file, void *data) | |
813 | { | |
814 | } | |
815 | ||
816 | static const struct seq_operations sched_debug_sops = { | |
97fb7a0a IM |
817 | .start = sched_debug_start, |
818 | .next = sched_debug_next, | |
819 | .stop = sched_debug_stop, | |
820 | .show = sched_debug_show, | |
bbbfeac9 NZ |
821 | }; |
822 | ||
43ae34cb IM |
823 | static int __init init_sched_debug_procfs(void) |
824 | { | |
fddda2b7 | 825 | if (!proc_create_seq("sched_debug", 0444, NULL, &sched_debug_sops)) |
43ae34cb | 826 | return -ENOMEM; |
43ae34cb IM |
827 | return 0; |
828 | } | |
829 | ||
830 | __initcall(init_sched_debug_procfs); | |
831 | ||
97fb7a0a IM |
832 | #define __P(F) SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)F) |
833 | #define P(F) SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)p->F) | |
834 | #define __PN(F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F)) | |
835 | #define PN(F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F)) | |
b32e86b4 IM |
836 | |
837 | ||
397f2378 SD |
838 | #ifdef CONFIG_NUMA_BALANCING |
839 | void print_numa_stats(struct seq_file *m, int node, unsigned long tsf, | |
840 | unsigned long tpf, unsigned long gsf, unsigned long gpf) | |
841 | { | |
842 | SEQ_printf(m, "numa_faults node=%d ", node); | |
67d9f6c2 SD |
843 | SEQ_printf(m, "task_private=%lu task_shared=%lu ", tpf, tsf); |
844 | SEQ_printf(m, "group_private=%lu group_shared=%lu\n", gpf, gsf); | |
397f2378 SD |
845 | } |
846 | #endif | |
847 | ||
848 | ||
b32e86b4 IM |
849 | static void sched_show_numa(struct task_struct *p, struct seq_file *m) |
850 | { | |
851 | #ifdef CONFIG_NUMA_BALANCING | |
852 | struct mempolicy *pol; | |
b32e86b4 IM |
853 | |
854 | if (p->mm) | |
855 | P(mm->numa_scan_seq); | |
856 | ||
857 | task_lock(p); | |
858 | pol = p->mempolicy; | |
859 | if (pol && !(pol->flags & MPOL_F_MORON)) | |
860 | pol = NULL; | |
861 | mpol_get(pol); | |
862 | task_unlock(p); | |
863 | ||
397f2378 SD |
864 | P(numa_pages_migrated); |
865 | P(numa_preferred_nid); | |
866 | P(total_numa_faults); | |
867 | SEQ_printf(m, "current_node=%d, numa_group_id=%d\n", | |
868 | task_node(p), task_numa_group_id(p)); | |
869 | show_numa_stats(p, m); | |
b32e86b4 IM |
870 | mpol_put(pol); |
871 | #endif | |
872 | } | |
873 | ||
74dc3384 AS |
874 | void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, |
875 | struct seq_file *m) | |
43ae34cb | 876 | { |
cc367732 | 877 | unsigned long nr_switches; |
43ae34cb | 878 | |
74dc3384 | 879 | SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, task_pid_nr_ns(p, ns), |
5089a976 | 880 | get_nr_threads(p)); |
2d92f227 | 881 | SEQ_printf(m, |
add332a1 KB |
882 | "---------------------------------------------------------" |
883 | "----------\n"); | |
cc367732 | 884 | #define __P(F) \ |
add332a1 | 885 | SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)F) |
43ae34cb | 886 | #define P(F) \ |
add332a1 | 887 | SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)p->F) |
4fa8d299 JP |
888 | #define P_SCHEDSTAT(F) \ |
889 | SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)schedstat_val(p->F)) | |
cc367732 | 890 | #define __PN(F) \ |
add332a1 | 891 | SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F)) |
ef83a571 | 892 | #define PN(F) \ |
add332a1 | 893 | SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F)) |
4fa8d299 JP |
894 | #define PN_SCHEDSTAT(F) \ |
895 | SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)schedstat_val(p->F))) | |
43ae34cb | 896 | |
ef83a571 IM |
897 | PN(se.exec_start); |
898 | PN(se.vruntime); | |
899 | PN(se.sum_exec_runtime); | |
6cfb0d5d | 900 | |
cc367732 IM |
901 | nr_switches = p->nvcsw + p->nivcsw; |
902 | ||
cc367732 | 903 | P(se.nr_migrations); |
cc367732 | 904 | |
cb251765 | 905 | if (schedstat_enabled()) { |
cc367732 IM |
906 | u64 avg_atom, avg_per_cpu; |
907 | ||
4fa8d299 JP |
908 | PN_SCHEDSTAT(se.statistics.sum_sleep_runtime); |
909 | PN_SCHEDSTAT(se.statistics.wait_start); | |
910 | PN_SCHEDSTAT(se.statistics.sleep_start); | |
911 | PN_SCHEDSTAT(se.statistics.block_start); | |
912 | PN_SCHEDSTAT(se.statistics.sleep_max); | |
913 | PN_SCHEDSTAT(se.statistics.block_max); | |
914 | PN_SCHEDSTAT(se.statistics.exec_max); | |
915 | PN_SCHEDSTAT(se.statistics.slice_max); | |
916 | PN_SCHEDSTAT(se.statistics.wait_max); | |
917 | PN_SCHEDSTAT(se.statistics.wait_sum); | |
918 | P_SCHEDSTAT(se.statistics.wait_count); | |
919 | PN_SCHEDSTAT(se.statistics.iowait_sum); | |
920 | P_SCHEDSTAT(se.statistics.iowait_count); | |
921 | P_SCHEDSTAT(se.statistics.nr_migrations_cold); | |
922 | P_SCHEDSTAT(se.statistics.nr_failed_migrations_affine); | |
923 | P_SCHEDSTAT(se.statistics.nr_failed_migrations_running); | |
924 | P_SCHEDSTAT(se.statistics.nr_failed_migrations_hot); | |
925 | P_SCHEDSTAT(se.statistics.nr_forced_migrations); | |
926 | P_SCHEDSTAT(se.statistics.nr_wakeups); | |
927 | P_SCHEDSTAT(se.statistics.nr_wakeups_sync); | |
928 | P_SCHEDSTAT(se.statistics.nr_wakeups_migrate); | |
929 | P_SCHEDSTAT(se.statistics.nr_wakeups_local); | |
930 | P_SCHEDSTAT(se.statistics.nr_wakeups_remote); | |
931 | P_SCHEDSTAT(se.statistics.nr_wakeups_affine); | |
932 | P_SCHEDSTAT(se.statistics.nr_wakeups_affine_attempts); | |
933 | P_SCHEDSTAT(se.statistics.nr_wakeups_passive); | |
934 | P_SCHEDSTAT(se.statistics.nr_wakeups_idle); | |
cb251765 | 935 | |
cc367732 IM |
936 | avg_atom = p->se.sum_exec_runtime; |
937 | if (nr_switches) | |
b0ab99e7 | 938 | avg_atom = div64_ul(avg_atom, nr_switches); |
cc367732 IM |
939 | else |
940 | avg_atom = -1LL; | |
941 | ||
942 | avg_per_cpu = p->se.sum_exec_runtime; | |
c1a89740 | 943 | if (p->se.nr_migrations) { |
6f6d6a1a RZ |
944 | avg_per_cpu = div64_u64(avg_per_cpu, |
945 | p->se.nr_migrations); | |
c1a89740 | 946 | } else { |
cc367732 | 947 | avg_per_cpu = -1LL; |
c1a89740 | 948 | } |
cc367732 IM |
949 | |
950 | __PN(avg_atom); | |
951 | __PN(avg_per_cpu); | |
952 | } | |
4fa8d299 | 953 | |
cc367732 | 954 | __P(nr_switches); |
add332a1 | 955 | SEQ_printf(m, "%-45s:%21Ld\n", |
cc367732 | 956 | "nr_voluntary_switches", (long long)p->nvcsw); |
add332a1 | 957 | SEQ_printf(m, "%-45s:%21Ld\n", |
cc367732 IM |
958 | "nr_involuntary_switches", (long long)p->nivcsw); |
959 | ||
43ae34cb | 960 | P(se.load.weight); |
1ea6c46a | 961 | P(se.runnable_weight); |
333bb864 | 962 | #ifdef CONFIG_SMP |
9d89c257 | 963 | P(se.avg.load_sum); |
1ea6c46a | 964 | P(se.avg.runnable_load_sum); |
9d89c257 YD |
965 | P(se.avg.util_sum); |
966 | P(se.avg.load_avg); | |
1ea6c46a | 967 | P(se.avg.runnable_load_avg); |
9d89c257 YD |
968 | P(se.avg.util_avg); |
969 | P(se.avg.last_update_time); | |
7f65ea42 PB |
970 | P(se.avg.util_est.ewma); |
971 | P(se.avg.util_est.enqueued); | |
939fd731 | 972 | #endif |
43ae34cb IM |
973 | P(policy); |
974 | P(prio); | |
59f8c298 TC |
975 | if (p->policy == SCHED_DEADLINE) { |
976 | P(dl.runtime); | |
977 | P(dl.deadline); | |
978 | } | |
4fa8d299 | 979 | #undef PN_SCHEDSTAT |
ef83a571 | 980 | #undef PN |
cc367732 | 981 | #undef __PN |
4fa8d299 | 982 | #undef P_SCHEDSTAT |
cc367732 IM |
983 | #undef P |
984 | #undef __P | |
43ae34cb IM |
985 | |
986 | { | |
29d7b90c | 987 | unsigned int this_cpu = raw_smp_processor_id(); |
43ae34cb IM |
988 | u64 t0, t1; |
989 | ||
29d7b90c IM |
990 | t0 = cpu_clock(this_cpu); |
991 | t1 = cpu_clock(this_cpu); | |
add332a1 | 992 | SEQ_printf(m, "%-45s:%21Ld\n", |
43ae34cb IM |
993 | "clock-delta", (long long)(t1-t0)); |
994 | } | |
b32e86b4 IM |
995 | |
996 | sched_show_numa(p, m); | |
43ae34cb IM |
997 | } |
998 | ||
999 | void proc_sched_set_task(struct task_struct *p) | |
1000 | { | |
6cfb0d5d | 1001 | #ifdef CONFIG_SCHEDSTATS |
41acab88 | 1002 | memset(&p->se.statistics, 0, sizeof(p->se.statistics)); |
6cfb0d5d | 1003 | #endif |
43ae34cb | 1004 | } |