4 * Print the CFS rbtree and other debugging details
6 * Copyright(C) 2007, Red Hat, Inc., Ingo Molnar
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.
15 * This allows printing both to /proc/sched_debug and
18 #define SEQ_printf(m, x...) \
27 * Ease the printing of nsec fields:
29 static long long nsec_high(unsigned long long nsec)
31 if ((long long)nsec < 0) {
33 do_div(nsec, 1000000);
36 do_div(nsec, 1000000);
41 static unsigned long nsec_low(unsigned long long nsec)
43 if ((long long)nsec < 0)
46 return do_div(nsec, 1000000);
49 #define SPLIT_NS(x) nsec_high(x), nsec_low(x)
51 #define SCHED_FEAT(name, enabled) \
54 static const char * const sched_feat_names[] = {
60 static int sched_feat_show(struct seq_file *m, void *v)
64 for (i = 0; i < __SCHED_FEAT_NR; i++) {
65 if (!(sysctl_sched_features & (1UL << i)))
67 seq_printf(m, "%s ", sched_feat_names[i]);
74 #ifdef CONFIG_JUMP_LABEL
76 #define jump_label_key__true STATIC_KEY_INIT_TRUE
77 #define jump_label_key__false STATIC_KEY_INIT_FALSE
79 #define SCHED_FEAT(name, enabled) \
80 jump_label_key__##enabled ,
82 struct static_key sched_feat_keys[__SCHED_FEAT_NR] = {
88 static void sched_feat_disable(int i)
90 static_key_disable_cpuslocked(&sched_feat_keys[i]);
93 static void sched_feat_enable(int i)
95 static_key_enable_cpuslocked(&sched_feat_keys[i]);
98 static void sched_feat_disable(int i) { };
99 static void sched_feat_enable(int i) { };
100 #endif /* CONFIG_JUMP_LABEL */
102 static int sched_feat_set(char *cmp)
107 if (strncmp(cmp, "NO_", 3) == 0) {
112 i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp);
117 sysctl_sched_features &= ~(1UL << i);
118 sched_feat_disable(i);
120 sysctl_sched_features |= (1UL << i);
121 sched_feat_enable(i);
128 sched_feat_write(struct file *filp, const char __user *ubuf,
129 size_t cnt, loff_t *ppos)
139 if (copy_from_user(&buf, ubuf, cnt))
145 /* Ensure the static_key remains in a consistent state */
146 inode = file_inode(filp);
149 ret = sched_feat_set(cmp);
160 static int sched_feat_open(struct inode *inode, struct file *filp)
162 return single_open(filp, sched_feat_show, NULL);
165 static const struct file_operations sched_feat_fops = {
166 .open = sched_feat_open,
167 .write = sched_feat_write,
170 .release = single_release,
173 __read_mostly bool sched_debug_enabled;
175 static __init int sched_init_debug(void)
177 debugfs_create_file("sched_features", 0644, NULL, NULL,
180 debugfs_create_bool("sched_debug", 0644, NULL,
181 &sched_debug_enabled);
185 late_initcall(sched_init_debug);
191 static struct ctl_table sd_ctl_dir[] = {
193 .procname = "sched_domain",
199 static struct ctl_table sd_ctl_root[] = {
201 .procname = "kernel",
208 static struct ctl_table *sd_alloc_ctl_entry(int n)
210 struct ctl_table *entry =
211 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
216 static void sd_free_ctl_entry(struct ctl_table **tablep)
218 struct ctl_table *entry;
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.
226 for (entry = *tablep; entry->mode; entry++) {
228 sd_free_ctl_entry(&entry->child);
229 if (entry->proc_handler == NULL)
230 kfree(entry->procname);
237 static int min_load_idx = 0;
238 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
241 set_table_entry(struct ctl_table *entry,
242 const char *procname, void *data, int maxlen,
243 umode_t mode, proc_handler *proc_handler,
246 entry->procname = procname;
248 entry->maxlen = maxlen;
250 entry->proc_handler = proc_handler;
253 entry->extra1 = &min_load_idx;
254 entry->extra2 = &max_load_idx;
258 static struct ctl_table *
259 sd_alloc_ctl_domain_table(struct sched_domain *sd)
261 struct ctl_table *table = sd_alloc_ctl_entry(14);
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);
279 /* &table[13] is terminator */
284 static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
286 struct ctl_table *entry, *table;
287 struct sched_domain *sd;
288 int domain_num = 0, i;
291 for_each_domain(cpu, sd)
293 entry = table = sd_alloc_ctl_entry(domain_num + 1);
298 for_each_domain(cpu, sd) {
299 snprintf(buf, 32, "domain%d", i);
300 entry->procname = kstrdup(buf, GFP_KERNEL);
302 entry->child = sd_alloc_ctl_domain_table(sd);
309 static cpumask_var_t sd_sysctl_cpus;
310 static struct ctl_table_header *sd_sysctl_header;
312 void register_sched_domain_sysctl(void)
314 static struct ctl_table *cpu_entries;
315 static struct ctl_table **cpu_idx;
316 static bool init_done = false;
321 cpu_entries = sd_alloc_ctl_entry(num_possible_cpus() + 1);
325 WARN_ON(sd_ctl_dir[0].child);
326 sd_ctl_dir[0].child = cpu_entries;
330 struct ctl_table *e = cpu_entries;
332 cpu_idx = kcalloc(nr_cpu_ids, sizeof(struct ctl_table*), GFP_KERNEL);
336 /* deal with sparse possible map */
337 for_each_possible_cpu(i) {
343 if (!cpumask_available(sd_sysctl_cpus)) {
344 if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
350 /* init to possible to not have holes in @cpu_entries */
351 cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
354 for_each_cpu(i, sd_sysctl_cpus) {
355 struct ctl_table *e = cpu_idx[i];
358 sd_free_ctl_entry(&e->child);
361 snprintf(buf, 32, "cpu%d", i);
362 e->procname = kstrdup(buf, GFP_KERNEL);
365 e->child = sd_alloc_ctl_cpu_table(i);
367 __cpumask_clear_cpu(i, sd_sysctl_cpus);
370 WARN_ON(sd_sysctl_header);
371 sd_sysctl_header = register_sysctl_table(sd_ctl_root);
374 void dirty_sched_domain_sysctl(int cpu)
376 if (cpumask_available(sd_sysctl_cpus))
377 __cpumask_set_cpu(cpu, sd_sysctl_cpus);
380 /* may be called multiple times per register */
381 void unregister_sched_domain_sysctl(void)
383 unregister_sysctl_table(sd_sysctl_header);
384 sd_sysctl_header = NULL;
386 #endif /* CONFIG_SYSCTL */
387 #endif /* CONFIG_SMP */
389 #ifdef CONFIG_FAIR_GROUP_SCHED
390 static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg)
392 struct sched_entity *se = tg->se[cpu];
394 #define P(F) SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)F)
395 #define P_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)schedstat_val(F))
396 #define PN(F) SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)F))
397 #define PN_SCHEDSTAT(F) SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)schedstat_val(F)))
404 PN(se->sum_exec_runtime);
406 if (schedstat_enabled()) {
407 PN_SCHEDSTAT(se->statistics.wait_start);
408 PN_SCHEDSTAT(se->statistics.sleep_start);
409 PN_SCHEDSTAT(se->statistics.block_start);
410 PN_SCHEDSTAT(se->statistics.sleep_max);
411 PN_SCHEDSTAT(se->statistics.block_max);
412 PN_SCHEDSTAT(se->statistics.exec_max);
413 PN_SCHEDSTAT(se->statistics.slice_max);
414 PN_SCHEDSTAT(se->statistics.wait_max);
415 PN_SCHEDSTAT(se->statistics.wait_sum);
416 P_SCHEDSTAT(se->statistics.wait_count);
420 P(se->runnable_weight);
424 P(se->avg.runnable_load_avg);
434 #ifdef CONFIG_CGROUP_SCHED
435 static DEFINE_SPINLOCK(sched_debug_lock);
436 static char group_path[PATH_MAX];
438 static void task_group_path(struct task_group *tg, char *path, int plen)
440 if (autogroup_path(tg, path, plen))
443 cgroup_path(tg->css.cgroup, path, plen);
447 * Only 1 SEQ_printf_task_group_path() caller can use the full length
448 * group_path[] for cgroup path. Other simultaneous callers will have
449 * to use a shorter stack buffer. A "..." suffix is appended at the end
450 * of the stack buffer so that it will show up in case the output length
451 * matches the given buffer size to indicate possible path name truncation.
453 #define SEQ_printf_task_group_path(m, tg, fmt...) \
455 if (spin_trylock(&sched_debug_lock)) { \
456 task_group_path(tg, group_path, sizeof(group_path)); \
457 SEQ_printf(m, fmt, group_path); \
458 spin_unlock(&sched_debug_lock); \
461 char *bufend = buf + sizeof(buf) - 3; \
462 task_group_path(tg, buf, bufend - buf); \
463 strcpy(bufend - 1, "..."); \
464 SEQ_printf(m, fmt, buf); \
470 print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
475 SEQ_printf(m, " %c", task_state_to_char(p));
477 SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ",
478 p->comm, task_pid_nr(p),
479 SPLIT_NS(p->se.vruntime),
480 (long long)(p->nvcsw + p->nivcsw),
483 SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld",
484 SPLIT_NS(schedstat_val_or_zero(p->se.statistics.wait_sum)),
485 SPLIT_NS(p->se.sum_exec_runtime),
486 SPLIT_NS(schedstat_val_or_zero(p->se.statistics.sum_sleep_runtime)));
488 #ifdef CONFIG_NUMA_BALANCING
489 SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
491 #ifdef CONFIG_CGROUP_SCHED
492 SEQ_printf_task_group_path(m, task_group(p), " %s")
498 static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
500 struct task_struct *g, *p;
503 SEQ_printf(m, "runnable tasks:\n");
504 SEQ_printf(m, " S task PID tree-key switches prio"
505 " wait-time sum-exec sum-sleep\n");
506 SEQ_printf(m, "-------------------------------------------------------"
507 "----------------------------------------------------\n");
510 for_each_process_thread(g, p) {
511 if (task_cpu(p) != rq_cpu)
514 print_task(m, rq, p);
519 void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
521 s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1,
522 spread, rq0_min_vruntime, spread0;
523 struct rq *rq = cpu_rq(cpu);
524 struct sched_entity *last;
527 #ifdef CONFIG_FAIR_GROUP_SCHED
529 SEQ_printf_task_group_path(m, cfs_rq->tg, "cfs_rq[%d]:%s\n", cpu);
532 SEQ_printf(m, "cfs_rq[%d]:\n", cpu);
534 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "exec_clock",
535 SPLIT_NS(cfs_rq->exec_clock));
537 raw_spin_lock_irqsave(&rq->lock, flags);
538 if (rb_first_cached(&cfs_rq->tasks_timeline))
539 MIN_vruntime = (__pick_first_entity(cfs_rq))->vruntime;
540 last = __pick_last_entity(cfs_rq);
542 max_vruntime = last->vruntime;
543 min_vruntime = cfs_rq->min_vruntime;
544 rq0_min_vruntime = cpu_rq(0)->cfs.min_vruntime;
545 raw_spin_unlock_irqrestore(&rq->lock, flags);
546 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "MIN_vruntime",
547 SPLIT_NS(MIN_vruntime));
548 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "min_vruntime",
549 SPLIT_NS(min_vruntime));
550 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "max_vruntime",
551 SPLIT_NS(max_vruntime));
552 spread = max_vruntime - MIN_vruntime;
553 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread",
555 spread0 = min_vruntime - rq0_min_vruntime;
556 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread0",
558 SEQ_printf(m, " .%-30s: %d\n", "nr_spread_over",
559 cfs_rq->nr_spread_over);
560 SEQ_printf(m, " .%-30s: %d\n", "nr_running", cfs_rq->nr_running);
561 SEQ_printf(m, " .%-30s: %ld\n", "load", cfs_rq->load.weight);
563 SEQ_printf(m, " .%-30s: %ld\n", "runnable_weight", cfs_rq->runnable_weight);
564 SEQ_printf(m, " .%-30s: %lu\n", "load_avg",
565 cfs_rq->avg.load_avg);
566 SEQ_printf(m, " .%-30s: %lu\n", "runnable_load_avg",
567 cfs_rq->avg.runnable_load_avg);
568 SEQ_printf(m, " .%-30s: %lu\n", "util_avg",
569 cfs_rq->avg.util_avg);
570 SEQ_printf(m, " .%-30s: %u\n", "util_est_enqueued",
571 cfs_rq->avg.util_est.enqueued);
572 SEQ_printf(m, " .%-30s: %ld\n", "removed.load_avg",
573 cfs_rq->removed.load_avg);
574 SEQ_printf(m, " .%-30s: %ld\n", "removed.util_avg",
575 cfs_rq->removed.util_avg);
576 SEQ_printf(m, " .%-30s: %ld\n", "removed.runnable_sum",
577 cfs_rq->removed.runnable_sum);
578 #ifdef CONFIG_FAIR_GROUP_SCHED
579 SEQ_printf(m, " .%-30s: %lu\n", "tg_load_avg_contrib",
580 cfs_rq->tg_load_avg_contrib);
581 SEQ_printf(m, " .%-30s: %ld\n", "tg_load_avg",
582 atomic_long_read(&cfs_rq->tg->load_avg));
585 #ifdef CONFIG_CFS_BANDWIDTH
586 SEQ_printf(m, " .%-30s: %d\n", "throttled",
588 SEQ_printf(m, " .%-30s: %d\n", "throttle_count",
589 cfs_rq->throttle_count);
592 #ifdef CONFIG_FAIR_GROUP_SCHED
593 print_cfs_group_stats(m, cpu, cfs_rq->tg);
597 void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)
599 #ifdef CONFIG_RT_GROUP_SCHED
601 SEQ_printf_task_group_path(m, rt_rq->tg, "rt_rq[%d]:%s\n", cpu);
604 SEQ_printf(m, "rt_rq[%d]:\n", cpu);
608 SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rt_rq->x))
610 SEQ_printf(m, " .%-30s: %lu\n", #x, (unsigned long)(rt_rq->x))
612 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rt_rq->x))
627 void print_dl_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq)
632 SEQ_printf(m, "dl_rq[%d]:\n", cpu);
635 SEQ_printf(m, " .%-30s: %lu\n", #x, (unsigned long)(dl_rq->x))
640 dl_bw = &cpu_rq(cpu)->rd->dl_bw;
642 dl_bw = &dl_rq->dl_bw;
644 SEQ_printf(m, " .%-30s: %lld\n", "dl_bw->bw", dl_bw->bw);
645 SEQ_printf(m, " .%-30s: %lld\n", "dl_bw->total_bw", dl_bw->total_bw);
650 static void print_cpu(struct seq_file *m, int cpu)
652 struct rq *rq = cpu_rq(cpu);
656 unsigned int freq = cpu_khz ? : 1;
658 SEQ_printf(m, "cpu#%d, %u.%03u MHz\n",
659 cpu, freq / 1000, (freq % 1000));
662 SEQ_printf(m, "cpu#%d\n", cpu);
667 if (sizeof(rq->x) == 4) \
668 SEQ_printf(m, " .%-30s: %ld\n", #x, (long)(rq->x)); \
670 SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rq->x));\
674 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rq->x))
677 SEQ_printf(m, " .%-30s: %lu\n", "load",
681 P(nr_uninterruptible);
683 SEQ_printf(m, " .%-30s: %ld\n", "curr->pid", (long)(task_pid_nr(rq->curr)));
695 #define P64(n) SEQ_printf(m, " .%-30s: %Ld\n", #n, rq->n);
697 P64(max_idle_balance_cost);
701 #define P(n) SEQ_printf(m, " .%-30s: %d\n", #n, schedstat_val(rq->n));
702 if (schedstat_enabled()) {
711 print_cfs_stats(m, cpu);
712 print_rt_stats(m, cpu);
713 print_dl_stats(m, cpu);
715 print_rq(m, rq, cpu);
719 static const char *sched_tunable_scaling_names[] = {
725 static void sched_debug_header(struct seq_file *m)
727 u64 ktime, sched_clk, cpu_clk;
730 local_irq_save(flags);
731 ktime = ktime_to_ns(ktime_get());
732 sched_clk = sched_clock();
733 cpu_clk = local_clock();
734 local_irq_restore(flags);
736 SEQ_printf(m, "Sched Debug Version: v0.11, %s %.*s\n",
737 init_utsname()->release,
738 (int)strcspn(init_utsname()->version, " "),
739 init_utsname()->version);
742 SEQ_printf(m, "%-40s: %Ld\n", #x, (long long)(x))
744 SEQ_printf(m, "%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
749 #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
750 P(sched_clock_stable());
756 SEQ_printf(m, "sysctl_sched\n");
759 SEQ_printf(m, " .%-40s: %Ld\n", #x, (long long)(x))
761 SEQ_printf(m, " .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
762 PN(sysctl_sched_latency);
763 PN(sysctl_sched_min_granularity);
764 PN(sysctl_sched_wakeup_granularity);
765 P(sysctl_sched_child_runs_first);
766 P(sysctl_sched_features);
770 SEQ_printf(m, " .%-40s: %d (%s)\n",
771 "sysctl_sched_tunable_scaling",
772 sysctl_sched_tunable_scaling,
773 sched_tunable_scaling_names[sysctl_sched_tunable_scaling]);
777 static int sched_debug_show(struct seq_file *m, void *v)
779 int cpu = (unsigned long)(v - 2);
784 sched_debug_header(m);
789 void sysrq_sched_debug_show(void)
793 sched_debug_header(NULL);
794 for_each_online_cpu(cpu)
795 print_cpu(NULL, cpu);
800 * This itererator needs some explanation.
801 * It returns 1 for the header position.
802 * This means 2 is CPU 0.
803 * In a hotplugged system some CPUs, including CPU 0, may be missing so we have
804 * to use cpumask_* to iterate over the CPUs.
806 static void *sched_debug_start(struct seq_file *file, loff_t *offset)
808 unsigned long n = *offset;
816 n = cpumask_next(n - 1, cpu_online_mask);
818 n = cpumask_first(cpu_online_mask);
823 return (void *)(unsigned long)(n + 2);
828 static void *sched_debug_next(struct seq_file *file, void *data, loff_t *offset)
831 return sched_debug_start(file, offset);
834 static void sched_debug_stop(struct seq_file *file, void *data)
838 static const struct seq_operations sched_debug_sops = {
839 .start = sched_debug_start,
840 .next = sched_debug_next,
841 .stop = sched_debug_stop,
842 .show = sched_debug_show,
845 static int __init init_sched_debug_procfs(void)
847 if (!proc_create_seq("sched_debug", 0444, NULL, &sched_debug_sops))
852 __initcall(init_sched_debug_procfs);
854 #define __P(F) SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)F)
855 #define P(F) SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)p->F)
856 #define __PN(F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F))
857 #define PN(F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F))
860 #ifdef CONFIG_NUMA_BALANCING
861 void print_numa_stats(struct seq_file *m, int node, unsigned long tsf,
862 unsigned long tpf, unsigned long gsf, unsigned long gpf)
864 SEQ_printf(m, "numa_faults node=%d ", node);
865 SEQ_printf(m, "task_private=%lu task_shared=%lu ", tpf, tsf);
866 SEQ_printf(m, "group_private=%lu group_shared=%lu\n", gpf, gsf);
871 static void sched_show_numa(struct task_struct *p, struct seq_file *m)
873 #ifdef CONFIG_NUMA_BALANCING
874 struct mempolicy *pol;
877 P(mm->numa_scan_seq);
881 if (pol && !(pol->flags & MPOL_F_MORON))
886 P(numa_pages_migrated);
887 P(numa_preferred_nid);
888 P(total_numa_faults);
889 SEQ_printf(m, "current_node=%d, numa_group_id=%d\n",
890 task_node(p), task_numa_group_id(p));
891 show_numa_stats(p, m);
896 void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
899 unsigned long nr_switches;
901 SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, task_pid_nr_ns(p, ns),
904 "---------------------------------------------------------"
907 SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)F)
909 SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)p->F)
910 #define P_SCHEDSTAT(F) \
911 SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)schedstat_val(p->F))
913 SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F))
915 SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F))
916 #define PN_SCHEDSTAT(F) \
917 SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)schedstat_val(p->F)))
921 PN(se.sum_exec_runtime);
923 nr_switches = p->nvcsw + p->nivcsw;
927 if (schedstat_enabled()) {
928 u64 avg_atom, avg_per_cpu;
930 PN_SCHEDSTAT(se.statistics.sum_sleep_runtime);
931 PN_SCHEDSTAT(se.statistics.wait_start);
932 PN_SCHEDSTAT(se.statistics.sleep_start);
933 PN_SCHEDSTAT(se.statistics.block_start);
934 PN_SCHEDSTAT(se.statistics.sleep_max);
935 PN_SCHEDSTAT(se.statistics.block_max);
936 PN_SCHEDSTAT(se.statistics.exec_max);
937 PN_SCHEDSTAT(se.statistics.slice_max);
938 PN_SCHEDSTAT(se.statistics.wait_max);
939 PN_SCHEDSTAT(se.statistics.wait_sum);
940 P_SCHEDSTAT(se.statistics.wait_count);
941 PN_SCHEDSTAT(se.statistics.iowait_sum);
942 P_SCHEDSTAT(se.statistics.iowait_count);
943 P_SCHEDSTAT(se.statistics.nr_migrations_cold);
944 P_SCHEDSTAT(se.statistics.nr_failed_migrations_affine);
945 P_SCHEDSTAT(se.statistics.nr_failed_migrations_running);
946 P_SCHEDSTAT(se.statistics.nr_failed_migrations_hot);
947 P_SCHEDSTAT(se.statistics.nr_forced_migrations);
948 P_SCHEDSTAT(se.statistics.nr_wakeups);
949 P_SCHEDSTAT(se.statistics.nr_wakeups_sync);
950 P_SCHEDSTAT(se.statistics.nr_wakeups_migrate);
951 P_SCHEDSTAT(se.statistics.nr_wakeups_local);
952 P_SCHEDSTAT(se.statistics.nr_wakeups_remote);
953 P_SCHEDSTAT(se.statistics.nr_wakeups_affine);
954 P_SCHEDSTAT(se.statistics.nr_wakeups_affine_attempts);
955 P_SCHEDSTAT(se.statistics.nr_wakeups_passive);
956 P_SCHEDSTAT(se.statistics.nr_wakeups_idle);
958 avg_atom = p->se.sum_exec_runtime;
960 avg_atom = div64_ul(avg_atom, nr_switches);
964 avg_per_cpu = p->se.sum_exec_runtime;
965 if (p->se.nr_migrations) {
966 avg_per_cpu = div64_u64(avg_per_cpu,
967 p->se.nr_migrations);
977 SEQ_printf(m, "%-45s:%21Ld\n",
978 "nr_voluntary_switches", (long long)p->nvcsw);
979 SEQ_printf(m, "%-45s:%21Ld\n",
980 "nr_involuntary_switches", (long long)p->nivcsw);
983 P(se.runnable_weight);
986 P(se.avg.runnable_load_sum);
989 P(se.avg.runnable_load_avg);
991 P(se.avg.last_update_time);
992 P(se.avg.util_est.ewma);
993 P(se.avg.util_est.enqueued);
997 if (p->policy == SCHED_DEADLINE) {
1009 unsigned int this_cpu = raw_smp_processor_id();
1012 t0 = cpu_clock(this_cpu);
1013 t1 = cpu_clock(this_cpu);
1014 SEQ_printf(m, "%-45s:%21Ld\n",
1015 "clock-delta", (long long)(t1-t0));
1018 sched_show_numa(p, m);
1021 void proc_sched_set_task(struct task_struct *p)
1023 #ifdef CONFIG_SCHEDSTATS
1024 memset(&p->se.statistics, 0, sizeof(p->se.statistics));