1 // SPDX-License-Identifier: GPL-2.0-only
5 * Print the CFS rbtree and other debugging details
7 * Copyright(C) 2007, Red Hat, Inc., Ingo Molnar
12 * This allows printing both to /proc/sched_debug and
15 #define SEQ_printf(m, x...) \
24 * Ease the printing of nsec fields:
26 static long long nsec_high(unsigned long long nsec)
28 if ((long long)nsec < 0) {
30 do_div(nsec, 1000000);
33 do_div(nsec, 1000000);
38 static unsigned long nsec_low(unsigned long long nsec)
40 if ((long long)nsec < 0)
43 return do_div(nsec, 1000000);
46 #define SPLIT_NS(x) nsec_high(x), nsec_low(x)
48 #define SCHED_FEAT(name, enabled) \
51 static const char * const sched_feat_names[] = {
57 static int sched_feat_show(struct seq_file *m, void *v)
61 for (i = 0; i < __SCHED_FEAT_NR; i++) {
62 if (!(sysctl_sched_features & (1UL << i)))
64 seq_printf(m, "%s ", sched_feat_names[i]);
71 #ifdef CONFIG_JUMP_LABEL
73 #define jump_label_key__true STATIC_KEY_INIT_TRUE
74 #define jump_label_key__false STATIC_KEY_INIT_FALSE
76 #define SCHED_FEAT(name, enabled) \
77 jump_label_key__##enabled ,
79 struct static_key sched_feat_keys[__SCHED_FEAT_NR] = {
85 static void sched_feat_disable(int i)
87 static_key_disable_cpuslocked(&sched_feat_keys[i]);
90 static void sched_feat_enable(int i)
92 static_key_enable_cpuslocked(&sched_feat_keys[i]);
95 static void sched_feat_disable(int i) { };
96 static void sched_feat_enable(int i) { };
97 #endif /* CONFIG_JUMP_LABEL */
99 static int sched_feat_set(char *cmp)
104 if (strncmp(cmp, "NO_", 3) == 0) {
109 i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp);
114 sysctl_sched_features &= ~(1UL << i);
115 sched_feat_disable(i);
117 sysctl_sched_features |= (1UL << i);
118 sched_feat_enable(i);
125 sched_feat_write(struct file *filp, const char __user *ubuf,
126 size_t cnt, loff_t *ppos)
136 if (copy_from_user(&buf, ubuf, cnt))
142 /* Ensure the static_key remains in a consistent state */
143 inode = file_inode(filp);
146 ret = sched_feat_set(cmp);
157 static int sched_feat_open(struct inode *inode, struct file *filp)
159 return single_open(filp, sched_feat_show, NULL);
162 static const struct file_operations sched_feat_fops = {
163 .open = sched_feat_open,
164 .write = sched_feat_write,
167 .release = single_release,
170 __read_mostly bool sched_debug_enabled;
172 static __init int sched_init_debug(void)
174 debugfs_create_file("sched_features", 0644, NULL, NULL,
177 debugfs_create_bool("sched_debug", 0644, NULL,
178 &sched_debug_enabled);
182 late_initcall(sched_init_debug);
188 static struct ctl_table sd_ctl_dir[] = {
190 .procname = "sched_domain",
196 static struct ctl_table sd_ctl_root[] = {
198 .procname = "kernel",
205 static struct ctl_table *sd_alloc_ctl_entry(int n)
207 struct ctl_table *entry =
208 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
213 static void sd_free_ctl_entry(struct ctl_table **tablep)
215 struct ctl_table *entry;
218 * In the intermediate directories, both the child directory and
219 * procname are dynamically allocated and could fail but the mode
220 * will always be set. In the lowest directory the names are
221 * static strings and all have proc handlers.
223 for (entry = *tablep; entry->mode; entry++) {
225 sd_free_ctl_entry(&entry->child);
226 if (entry->proc_handler == NULL)
227 kfree(entry->procname);
235 set_table_entry(struct ctl_table *entry,
236 const char *procname, void *data, int maxlen,
237 umode_t mode, proc_handler *proc_handler)
239 entry->procname = procname;
241 entry->maxlen = maxlen;
243 entry->proc_handler = proc_handler;
246 static struct ctl_table *
247 sd_alloc_ctl_domain_table(struct sched_domain *sd)
249 struct ctl_table *table = sd_alloc_ctl_entry(9);
254 set_table_entry(&table[0], "min_interval", &sd->min_interval, sizeof(long), 0644, proc_doulongvec_minmax);
255 set_table_entry(&table[1], "max_interval", &sd->max_interval, sizeof(long), 0644, proc_doulongvec_minmax);
256 set_table_entry(&table[2], "busy_factor", &sd->busy_factor, sizeof(int), 0644, proc_dointvec_minmax);
257 set_table_entry(&table[3], "imbalance_pct", &sd->imbalance_pct, sizeof(int), 0644, proc_dointvec_minmax);
258 set_table_entry(&table[4], "cache_nice_tries", &sd->cache_nice_tries, sizeof(int), 0644, proc_dointvec_minmax);
259 set_table_entry(&table[5], "flags", &sd->flags, sizeof(int), 0444, proc_dointvec_minmax);
260 set_table_entry(&table[6], "max_newidle_lb_cost", &sd->max_newidle_lb_cost, sizeof(long), 0644, proc_doulongvec_minmax);
261 set_table_entry(&table[7], "name", sd->name, CORENAME_MAX_SIZE, 0444, proc_dostring);
262 /* &table[8] is terminator */
267 static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
269 struct ctl_table *entry, *table;
270 struct sched_domain *sd;
271 int domain_num = 0, i;
274 for_each_domain(cpu, sd)
276 entry = table = sd_alloc_ctl_entry(domain_num + 1);
281 for_each_domain(cpu, sd) {
282 snprintf(buf, 32, "domain%d", i);
283 entry->procname = kstrdup(buf, GFP_KERNEL);
285 entry->child = sd_alloc_ctl_domain_table(sd);
292 static cpumask_var_t sd_sysctl_cpus;
293 static struct ctl_table_header *sd_sysctl_header;
295 void register_sched_domain_sysctl(void)
297 static struct ctl_table *cpu_entries;
298 static struct ctl_table **cpu_idx;
299 static bool init_done = false;
304 cpu_entries = sd_alloc_ctl_entry(num_possible_cpus() + 1);
308 WARN_ON(sd_ctl_dir[0].child);
309 sd_ctl_dir[0].child = cpu_entries;
313 struct ctl_table *e = cpu_entries;
315 cpu_idx = kcalloc(nr_cpu_ids, sizeof(struct ctl_table*), GFP_KERNEL);
319 /* deal with sparse possible map */
320 for_each_possible_cpu(i) {
326 if (!cpumask_available(sd_sysctl_cpus)) {
327 if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
333 /* init to possible to not have holes in @cpu_entries */
334 cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
337 for_each_cpu(i, sd_sysctl_cpus) {
338 struct ctl_table *e = cpu_idx[i];
341 sd_free_ctl_entry(&e->child);
344 snprintf(buf, 32, "cpu%d", i);
345 e->procname = kstrdup(buf, GFP_KERNEL);
348 e->child = sd_alloc_ctl_cpu_table(i);
350 __cpumask_clear_cpu(i, sd_sysctl_cpus);
353 WARN_ON(sd_sysctl_header);
354 sd_sysctl_header = register_sysctl_table(sd_ctl_root);
357 void dirty_sched_domain_sysctl(int cpu)
359 if (cpumask_available(sd_sysctl_cpus))
360 __cpumask_set_cpu(cpu, sd_sysctl_cpus);
363 /* may be called multiple times per register */
364 void unregister_sched_domain_sysctl(void)
366 unregister_sysctl_table(sd_sysctl_header);
367 sd_sysctl_header = NULL;
369 #endif /* CONFIG_SYSCTL */
370 #endif /* CONFIG_SMP */
372 #ifdef CONFIG_FAIR_GROUP_SCHED
373 static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg)
375 struct sched_entity *se = tg->se[cpu];
377 #define P(F) SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)F)
378 #define P_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)schedstat_val(F))
379 #define PN(F) SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)F))
380 #define PN_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)schedstat_val(F)))
387 PN(se->sum_exec_runtime);
389 if (schedstat_enabled()) {
390 PN_SCHEDSTAT(se->statistics.wait_start);
391 PN_SCHEDSTAT(se->statistics.sleep_start);
392 PN_SCHEDSTAT(se->statistics.block_start);
393 PN_SCHEDSTAT(se->statistics.sleep_max);
394 PN_SCHEDSTAT(se->statistics.block_max);
395 PN_SCHEDSTAT(se->statistics.exec_max);
396 PN_SCHEDSTAT(se->statistics.slice_max);
397 PN_SCHEDSTAT(se->statistics.wait_max);
398 PN_SCHEDSTAT(se->statistics.wait_sum);
399 P_SCHEDSTAT(se->statistics.wait_count);
403 P(se->runnable_weight);
407 P(se->avg.runnable_load_avg);
417 #ifdef CONFIG_CGROUP_SCHED
418 static DEFINE_SPINLOCK(sched_debug_lock);
419 static char group_path[PATH_MAX];
421 static void task_group_path(struct task_group *tg, char *path, int plen)
423 if (autogroup_path(tg, path, plen))
426 cgroup_path(tg->css.cgroup, path, plen);
430 * Only 1 SEQ_printf_task_group_path() caller can use the full length
431 * group_path[] for cgroup path. Other simultaneous callers will have
432 * to use a shorter stack buffer. A "..." suffix is appended at the end
433 * of the stack buffer so that it will show up in case the output length
434 * matches the given buffer size to indicate possible path name truncation.
436 #define SEQ_printf_task_group_path(m, tg, fmt...) \
438 if (spin_trylock(&sched_debug_lock)) { \
439 task_group_path(tg, group_path, sizeof(group_path)); \
440 SEQ_printf(m, fmt, group_path); \
441 spin_unlock(&sched_debug_lock); \
444 char *bufend = buf + sizeof(buf) - 3; \
445 task_group_path(tg, buf, bufend - buf); \
446 strcpy(bufend - 1, "..."); \
447 SEQ_printf(m, fmt, buf); \
453 print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
458 SEQ_printf(m, " %c", task_state_to_char(p));
460 SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ",
461 p->comm, task_pid_nr(p),
462 SPLIT_NS(p->se.vruntime),
463 (long long)(p->nvcsw + p->nivcsw),
466 SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld",
467 SPLIT_NS(schedstat_val_or_zero(p->se.statistics.wait_sum)),
468 SPLIT_NS(p->se.sum_exec_runtime),
469 SPLIT_NS(schedstat_val_or_zero(p->se.statistics.sum_sleep_runtime)));
471 #ifdef CONFIG_NUMA_BALANCING
472 SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
474 #ifdef CONFIG_CGROUP_SCHED
475 SEQ_printf_task_group_path(m, task_group(p), " %s")
481 static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
483 struct task_struct *g, *p;
486 SEQ_printf(m, "runnable tasks:\n");
487 SEQ_printf(m, " S task PID tree-key switches prio"
488 " wait-time sum-exec sum-sleep\n");
489 SEQ_printf(m, "-------------------------------------------------------"
490 "----------------------------------------------------\n");
493 for_each_process_thread(g, p) {
494 if (task_cpu(p) != rq_cpu)
497 print_task(m, rq, p);
502 void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
504 s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1,
505 spread, rq0_min_vruntime, spread0;
506 struct rq *rq = cpu_rq(cpu);
507 struct sched_entity *last;
510 #ifdef CONFIG_FAIR_GROUP_SCHED
512 SEQ_printf_task_group_path(m, cfs_rq->tg, "cfs_rq[%d]:%s\n", cpu);
515 SEQ_printf(m, "cfs_rq[%d]:\n", cpu);
517 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "exec_clock",
518 SPLIT_NS(cfs_rq->exec_clock));
520 raw_spin_lock_irqsave(&rq->lock, flags);
521 if (rb_first_cached(&cfs_rq->tasks_timeline))
522 MIN_vruntime = (__pick_first_entity(cfs_rq))->vruntime;
523 last = __pick_last_entity(cfs_rq);
525 max_vruntime = last->vruntime;
526 min_vruntime = cfs_rq->min_vruntime;
527 rq0_min_vruntime = cpu_rq(0)->cfs.min_vruntime;
528 raw_spin_unlock_irqrestore(&rq->lock, flags);
529 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "MIN_vruntime",
530 SPLIT_NS(MIN_vruntime));
531 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "min_vruntime",
532 SPLIT_NS(min_vruntime));
533 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "max_vruntime",
534 SPLIT_NS(max_vruntime));
535 spread = max_vruntime - MIN_vruntime;
536 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread",
538 spread0 = min_vruntime - rq0_min_vruntime;
539 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread0",
541 SEQ_printf(m, " .%-30s: %d\n", "nr_spread_over",
542 cfs_rq->nr_spread_over);
543 SEQ_printf(m, " .%-30s: %d\n", "nr_running", cfs_rq->nr_running);
544 SEQ_printf(m, " .%-30s: %ld\n", "load", cfs_rq->load.weight);
546 SEQ_printf(m, " .%-30s: %ld\n", "runnable_weight", cfs_rq->runnable_weight);
547 SEQ_printf(m, " .%-30s: %lu\n", "load_avg",
548 cfs_rq->avg.load_avg);
549 SEQ_printf(m, " .%-30s: %lu\n", "runnable_load_avg",
550 cfs_rq->avg.runnable_load_avg);
551 SEQ_printf(m, " .%-30s: %lu\n", "util_avg",
552 cfs_rq->avg.util_avg);
553 SEQ_printf(m, " .%-30s: %u\n", "util_est_enqueued",
554 cfs_rq->avg.util_est.enqueued);
555 SEQ_printf(m, " .%-30s: %ld\n", "removed.load_avg",
556 cfs_rq->removed.load_avg);
557 SEQ_printf(m, " .%-30s: %ld\n", "removed.util_avg",
558 cfs_rq->removed.util_avg);
559 SEQ_printf(m, " .%-30s: %ld\n", "removed.runnable_sum",
560 cfs_rq->removed.runnable_sum);
561 #ifdef CONFIG_FAIR_GROUP_SCHED
562 SEQ_printf(m, " .%-30s: %lu\n", "tg_load_avg_contrib",
563 cfs_rq->tg_load_avg_contrib);
564 SEQ_printf(m, " .%-30s: %ld\n", "tg_load_avg",
565 atomic_long_read(&cfs_rq->tg->load_avg));
568 #ifdef CONFIG_CFS_BANDWIDTH
569 SEQ_printf(m, " .%-30s: %d\n", "throttled",
571 SEQ_printf(m, " .%-30s: %d\n", "throttle_count",
572 cfs_rq->throttle_count);
575 #ifdef CONFIG_FAIR_GROUP_SCHED
576 print_cfs_group_stats(m, cpu, cfs_rq->tg);
580 void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)
582 #ifdef CONFIG_RT_GROUP_SCHED
584 SEQ_printf_task_group_path(m, rt_rq->tg, "rt_rq[%d]:%s\n", cpu);
587 SEQ_printf(m, "rt_rq[%d]:\n", cpu);
591 SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rt_rq->x))
593 SEQ_printf(m, " .%-30s: %lu\n", #x, (unsigned long)(rt_rq->x))
595 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rt_rq->x))
610 void print_dl_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq)
615 SEQ_printf(m, "dl_rq[%d]:\n", cpu);
618 SEQ_printf(m, " .%-30s: %lu\n", #x, (unsigned long)(dl_rq->x))
623 dl_bw = &cpu_rq(cpu)->rd->dl_bw;
625 dl_bw = &dl_rq->dl_bw;
627 SEQ_printf(m, " .%-30s: %lld\n", "dl_bw->bw", dl_bw->bw);
628 SEQ_printf(m, " .%-30s: %lld\n", "dl_bw->total_bw", dl_bw->total_bw);
633 static void print_cpu(struct seq_file *m, int cpu)
635 struct rq *rq = cpu_rq(cpu);
639 unsigned int freq = cpu_khz ? : 1;
641 SEQ_printf(m, "cpu#%d, %u.%03u MHz\n",
642 cpu, freq / 1000, (freq % 1000));
645 SEQ_printf(m, "cpu#%d\n", cpu);
650 if (sizeof(rq->x) == 4) \
651 SEQ_printf(m, " .%-30s: %ld\n", #x, (long)(rq->x)); \
653 SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rq->x));\
657 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rq->x))
662 P(nr_uninterruptible);
664 SEQ_printf(m, " .%-30s: %ld\n", "curr->pid", (long)(task_pid_nr(rq->curr)));
671 #define P64(n) SEQ_printf(m, " .%-30s: %Ld\n", #n, rq->n);
673 P64(max_idle_balance_cost);
677 #define P(n) SEQ_printf(m, " .%-30s: %d\n", #n, schedstat_val(rq->n));
678 if (schedstat_enabled()) {
687 print_cfs_stats(m, cpu);
688 print_rt_stats(m, cpu);
689 print_dl_stats(m, cpu);
691 print_rq(m, rq, cpu);
695 static const char *sched_tunable_scaling_names[] = {
701 static void sched_debug_header(struct seq_file *m)
703 u64 ktime, sched_clk, cpu_clk;
706 local_irq_save(flags);
707 ktime = ktime_to_ns(ktime_get());
708 sched_clk = sched_clock();
709 cpu_clk = local_clock();
710 local_irq_restore(flags);
712 SEQ_printf(m, "Sched Debug Version: v0.11, %s %.*s\n",
713 init_utsname()->release,
714 (int)strcspn(init_utsname()->version, " "),
715 init_utsname()->version);
718 SEQ_printf(m, "%-40s: %Ld\n", #x, (long long)(x))
720 SEQ_printf(m, "%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
725 #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
726 P(sched_clock_stable());
732 SEQ_printf(m, "sysctl_sched\n");
735 SEQ_printf(m, " .%-40s: %Ld\n", #x, (long long)(x))
737 SEQ_printf(m, " .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
738 PN(sysctl_sched_latency);
739 PN(sysctl_sched_min_granularity);
740 PN(sysctl_sched_wakeup_granularity);
741 P(sysctl_sched_child_runs_first);
742 P(sysctl_sched_features);
746 SEQ_printf(m, " .%-40s: %d (%s)\n",
747 "sysctl_sched_tunable_scaling",
748 sysctl_sched_tunable_scaling,
749 sched_tunable_scaling_names[sysctl_sched_tunable_scaling]);
753 static int sched_debug_show(struct seq_file *m, void *v)
755 int cpu = (unsigned long)(v - 2);
760 sched_debug_header(m);
765 void sysrq_sched_debug_show(void)
769 sched_debug_header(NULL);
770 for_each_online_cpu(cpu)
771 print_cpu(NULL, cpu);
776 * This itererator needs some explanation.
777 * It returns 1 for the header position.
778 * This means 2 is CPU 0.
779 * In a hotplugged system some CPUs, including CPU 0, may be missing so we have
780 * to use cpumask_* to iterate over the CPUs.
782 static void *sched_debug_start(struct seq_file *file, loff_t *offset)
784 unsigned long n = *offset;
792 n = cpumask_next(n - 1, cpu_online_mask);
794 n = cpumask_first(cpu_online_mask);
799 return (void *)(unsigned long)(n + 2);
804 static void *sched_debug_next(struct seq_file *file, void *data, loff_t *offset)
807 return sched_debug_start(file, offset);
810 static void sched_debug_stop(struct seq_file *file, void *data)
814 static const struct seq_operations sched_debug_sops = {
815 .start = sched_debug_start,
816 .next = sched_debug_next,
817 .stop = sched_debug_stop,
818 .show = sched_debug_show,
821 static int __init init_sched_debug_procfs(void)
823 if (!proc_create_seq("sched_debug", 0444, NULL, &sched_debug_sops))
828 __initcall(init_sched_debug_procfs);
830 #define __P(F) SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)F)
831 #define P(F) SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)p->F)
832 #define __PN(F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F))
833 #define PN(F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F))
836 #ifdef CONFIG_NUMA_BALANCING
837 void print_numa_stats(struct seq_file *m, int node, unsigned long tsf,
838 unsigned long tpf, unsigned long gsf, unsigned long gpf)
840 SEQ_printf(m, "numa_faults node=%d ", node);
841 SEQ_printf(m, "task_private=%lu task_shared=%lu ", tpf, tsf);
842 SEQ_printf(m, "group_private=%lu group_shared=%lu\n", gpf, gsf);
847 static void sched_show_numa(struct task_struct *p, struct seq_file *m)
849 #ifdef CONFIG_NUMA_BALANCING
851 P(mm->numa_scan_seq);
853 P(numa_pages_migrated);
854 P(numa_preferred_nid);
855 P(total_numa_faults);
856 SEQ_printf(m, "current_node=%d, numa_group_id=%d\n",
857 task_node(p), task_numa_group_id(p));
858 show_numa_stats(p, m);
862 void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
865 unsigned long nr_switches;
867 SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, task_pid_nr_ns(p, ns),
870 "---------------------------------------------------------"
873 SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)F)
875 SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)p->F)
876 #define P_SCHEDSTAT(F) \
877 SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)schedstat_val(p->F))
879 SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F))
881 SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F))
882 #define PN_SCHEDSTAT(F) \
883 SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)schedstat_val(p->F)))
887 PN(se.sum_exec_runtime);
889 nr_switches = p->nvcsw + p->nivcsw;
893 if (schedstat_enabled()) {
894 u64 avg_atom, avg_per_cpu;
896 PN_SCHEDSTAT(se.statistics.sum_sleep_runtime);
897 PN_SCHEDSTAT(se.statistics.wait_start);
898 PN_SCHEDSTAT(se.statistics.sleep_start);
899 PN_SCHEDSTAT(se.statistics.block_start);
900 PN_SCHEDSTAT(se.statistics.sleep_max);
901 PN_SCHEDSTAT(se.statistics.block_max);
902 PN_SCHEDSTAT(se.statistics.exec_max);
903 PN_SCHEDSTAT(se.statistics.slice_max);
904 PN_SCHEDSTAT(se.statistics.wait_max);
905 PN_SCHEDSTAT(se.statistics.wait_sum);
906 P_SCHEDSTAT(se.statistics.wait_count);
907 PN_SCHEDSTAT(se.statistics.iowait_sum);
908 P_SCHEDSTAT(se.statistics.iowait_count);
909 P_SCHEDSTAT(se.statistics.nr_migrations_cold);
910 P_SCHEDSTAT(se.statistics.nr_failed_migrations_affine);
911 P_SCHEDSTAT(se.statistics.nr_failed_migrations_running);
912 P_SCHEDSTAT(se.statistics.nr_failed_migrations_hot);
913 P_SCHEDSTAT(se.statistics.nr_forced_migrations);
914 P_SCHEDSTAT(se.statistics.nr_wakeups);
915 P_SCHEDSTAT(se.statistics.nr_wakeups_sync);
916 P_SCHEDSTAT(se.statistics.nr_wakeups_migrate);
917 P_SCHEDSTAT(se.statistics.nr_wakeups_local);
918 P_SCHEDSTAT(se.statistics.nr_wakeups_remote);
919 P_SCHEDSTAT(se.statistics.nr_wakeups_affine);
920 P_SCHEDSTAT(se.statistics.nr_wakeups_affine_attempts);
921 P_SCHEDSTAT(se.statistics.nr_wakeups_passive);
922 P_SCHEDSTAT(se.statistics.nr_wakeups_idle);
924 avg_atom = p->se.sum_exec_runtime;
926 avg_atom = div64_ul(avg_atom, nr_switches);
930 avg_per_cpu = p->se.sum_exec_runtime;
931 if (p->se.nr_migrations) {
932 avg_per_cpu = div64_u64(avg_per_cpu,
933 p->se.nr_migrations);
943 SEQ_printf(m, "%-45s:%21Ld\n",
944 "nr_voluntary_switches", (long long)p->nvcsw);
945 SEQ_printf(m, "%-45s:%21Ld\n",
946 "nr_involuntary_switches", (long long)p->nivcsw);
949 P(se.runnable_weight);
952 P(se.avg.runnable_load_sum);
955 P(se.avg.runnable_load_avg);
957 P(se.avg.last_update_time);
958 P(se.avg.util_est.ewma);
959 P(se.avg.util_est.enqueued);
963 if (task_has_dl_policy(p)) {
975 unsigned int this_cpu = raw_smp_processor_id();
978 t0 = cpu_clock(this_cpu);
979 t1 = cpu_clock(this_cpu);
980 SEQ_printf(m, "%-45s:%21Ld\n",
981 "clock-delta", (long long)(t1-t0));
984 sched_show_numa(p, m);
987 void proc_sched_set_task(struct task_struct *p)
989 #ifdef CONFIG_SCHEDSTATS
990 memset(&p->se.statistics, 0, sizeof(p->se.statistics));