14 #include <linux/sched.h>
17 #include <linux/utsname.h>
27 #define SEQ_printf(m, x...) \
38 static long long nsec_high(
unsigned long long nsec)
40 if ((
long long)nsec < 0) {
50 static unsigned long nsec_low(
unsigned long long nsec)
52 if ((
long long)nsec < 0)
55 return do_div(nsec, 1000000);
58 #define SPLIT_NS(x) nsec_high(x), nsec_low(x)
60 #ifdef CONFIG_FAIR_GROUP_SCHED
61 static void print_cfs_group_stats(
struct seq_file *
m,
int cpu,
struct task_group *tg)
68 SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)F)
70 SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)F))
75 #ifdef CONFIG_SCHEDSTATS
76 PN(se->statistics.wait_start);
77 PN(se->statistics.sleep_start);
78 PN(se->statistics.block_start);
79 PN(se->statistics.sleep_max);
80 PN(se->statistics.block_max);
81 PN(se->statistics.exec_max);
82 PN(se->statistics.slice_max);
83 PN(se->statistics.wait_max);
84 PN(se->statistics.wait_sum);
85 P(se->statistics.wait_count);
93 #ifdef CONFIG_CGROUP_SCHED
96 static char *task_group_path(
struct task_group *tg)
98 if (autogroup_path(tg, group_path,
PATH_MAX))
104 if (!tg->css.cgroup) {
105 group_path[0] =
'\0';
121 SEQ_printf(m,
"%15s %5d %9Ld.%06ld %9Ld %5d ",
126 #ifdef CONFIG_SCHEDSTATS
127 SEQ_printf(m,
"%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld",
130 SPLIT_NS(p->
se.statistics.sum_sleep_runtime));
132 SEQ_printf(m,
"%15Ld %15Ld %15Ld.%06ld %15Ld.%06ld %15Ld.%06ld",
135 #ifdef CONFIG_CGROUP_SCHED
136 SEQ_printf(m,
" %s", task_group_path(task_group(p)));
142 static void print_rq(
struct seq_file *m,
struct rq *rq,
int rq_cpu)
148 "\nrunnable tasks:\n"
149 " task PID tree-key switches prio"
150 " exec-runtime sum-exec sum-sleep\n"
151 "------------------------------------------------------"
152 "----------------------------------------------------\n");
157 if (!p->
on_rq || task_cpu(p) != rq_cpu)
160 print_task(m, rq, p);
168 s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1,
169 spread, rq0_min_vruntime, spread0;
170 struct rq *rq =
cpu_rq(cpu);
174 #ifdef CONFIG_FAIR_GROUP_SCHED
175 SEQ_printf(m,
"\ncfs_rq[%d]:%s\n", cpu, task_group_path(cfs_rq->tg));
179 SEQ_printf(m,
" .%-30s: %Ld.%06ld\n",
"exec_clock",
189 rq0_min_vruntime =
cpu_rq(0)->cfs.min_vruntime;
191 SEQ_printf(m,
" .%-30s: %Ld.%06ld\n",
"MIN_vruntime",
193 SEQ_printf(m,
" .%-30s: %Ld.%06ld\n",
"min_vruntime",
195 SEQ_printf(m,
" .%-30s: %Ld.%06ld\n",
"max_vruntime",
197 spread = max_vruntime - MIN_vruntime;
198 SEQ_printf(m,
" .%-30s: %Ld.%06ld\n",
"spread",
200 spread0 = min_vruntime - rq0_min_vruntime;
201 SEQ_printf(m,
" .%-30s: %Ld.%06ld\n",
"spread0",
203 SEQ_printf(m,
" .%-30s: %d\n",
"nr_spread_over",
204 cfs_rq->nr_spread_over);
207 #ifdef CONFIG_FAIR_GROUP_SCHED
209 SEQ_printf(m,
" .%-30s: %Ld.%06ld\n",
"load_avg",
211 SEQ_printf(m,
" .%-30s: %Ld.%06ld\n",
"load_period",
213 SEQ_printf(m,
" .%-30s: %ld\n",
"load_contrib",
214 cfs_rq->load_contribution);
219 print_cfs_group_stats(m, cpu, cfs_rq->tg);
225 #ifdef CONFIG_RT_GROUP_SCHED
226 SEQ_printf(m,
"\nrt_rq[%d]:%s\n", cpu, task_group_path(rt_rq->tg));
232 SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rt_rq->x))
234 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rt_rq->x))
249 struct rq *rq =
cpu_rq(cpu);
257 cpu, freq / 1000, (freq % 1000));
265 if (sizeof(rq->x) == 4) \
266 SEQ_printf(m, " .%-30s: %ld\n", #x, (long)(rq->x)); \
268 SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rq->x));\
272 SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rq->x))
291 #ifdef CONFIG_SCHEDSTATS
292 #define P(n) SEQ_printf(m, " .%-30s: %d\n", #n, rq->n);
293 #define P64(n) SEQ_printf(m, " .%-30s: %Ld\n", #n, rq->n);
314 print_rq(m, rq, cpu);
316 spin_unlock_irqrestore(&sched_debug_lock, flags);
319 static const char *sched_tunable_scaling_names[] = {
325 static int sched_debug_show(
struct seq_file *m,
void *
v)
337 SEQ_printf(m,
"Sched Debug Version: v0.10, %s %.*s\n",
343 SEQ_printf(m, "%-40s: %Ld\n", #x, (long long)(x))
345 SEQ_printf(m, "%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
350 #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
351 P(sched_clock_stable);
360 SEQ_printf(m, " .%-40s: %Ld\n", #x, (long long)(x))
362 SEQ_printf(m, " .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
366 P(sysctl_sched_child_runs_first);
371 SEQ_printf(m,
" .%-40s: %d (%s)\n",
"sysctl_sched_tunable_scaling",
388 static int sched_debug_open(
struct inode *
inode,
struct file *filp)
394 .open = sched_debug_open,
400 static int __init init_sched_debug_procfs(
void)
404 pe = proc_create(
"sched_debug", 0444,
NULL, &sched_debug_fops);
414 unsigned long nr_switches;
419 "---------------------------------------------------------\n");
421 SEQ_printf(m, "%-35s:%21Ld\n", #F, (long long)F)
423 SEQ_printf(m, "%-35s:%21Ld\n", #F, (long long)p->F)
425 SEQ_printf(m, "%-35s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F))
427 SEQ_printf(m, "%-35s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F))
431 PN(se.sum_exec_runtime);
435 #ifdef CONFIG_SCHEDSTATS
436 PN(se.statistics.wait_start);
437 PN(se.statistics.sleep_start);
438 PN(se.statistics.block_start);
439 PN(se.statistics.sleep_max);
440 PN(se.statistics.block_max);
441 PN(se.statistics.exec_max);
442 PN(se.statistics.slice_max);
443 PN(se.statistics.wait_max);
444 PN(se.statistics.wait_sum);
445 P(se.statistics.wait_count);
446 PN(se.statistics.iowait_sum);
447 P(se.statistics.iowait_count);
449 P(se.statistics.nr_migrations_cold);
450 P(se.statistics.nr_failed_migrations_affine);
451 P(se.statistics.nr_failed_migrations_running);
452 P(se.statistics.nr_failed_migrations_hot);
453 P(se.statistics.nr_forced_migrations);
454 P(se.statistics.nr_wakeups);
455 P(se.statistics.nr_wakeups_sync);
456 P(se.statistics.nr_wakeups_migrate);
457 P(se.statistics.nr_wakeups_local);
458 P(se.statistics.nr_wakeups_remote);
459 P(se.statistics.nr_wakeups_affine);
460 P(se.statistics.nr_wakeups_affine_attempts);
461 P(se.statistics.nr_wakeups_passive);
462 P(se.statistics.nr_wakeups_idle);
465 u64 avg_atom, avg_per_cpu;
467 avg_atom = p->
se.sum_exec_runtime;
469 do_div(avg_atom, nr_switches);
473 avg_per_cpu = p->
se.sum_exec_runtime;
474 if (p->
se.nr_migrations) {
475 avg_per_cpu = div64_u64(avg_per_cpu,
476 p->
se.nr_migrations);
487 "nr_voluntary_switches", (
long long)p->
nvcsw);
489 "nr_involuntary_switches", (
long long)p->
nivcsw);
506 "clock-delta", (
long long)(t1-t0));
512 #ifdef CONFIG_SCHEDSTATS
513 memset(&p->
se.statistics, 0,
sizeof(p->
se.statistics));