debug.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /*
  2. * kernel/sched/debug.c
  3. *
  4. * Print the CFS rbtree
  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. */
  12. #include <linux/proc_fs.h>
  13. #include <linux/sched.h>
  14. #include <linux/seq_file.h>
  15. #include <linux/kallsyms.h>
  16. #include <linux/utsname.h>
  17. #include <linux/mempolicy.h>
  18. #include "sched.h"
  19. static DEFINE_SPINLOCK(sched_debug_lock);
  20. /*
  21. * This allows printing both to /proc/sched_debug and
  22. * to the console
  23. */
  24. #define SEQ_printf(m, x...) \
  25. do { \
  26. if (m) \
  27. seq_printf(m, x); \
  28. else \
  29. printk(x); \
  30. } while (0)
  31. /*
  32. * Ease the printing of nsec fields:
  33. */
  34. static long long nsec_high(unsigned long long nsec)
  35. {
  36. if ((long long)nsec < 0) {
  37. nsec = -nsec;
  38. do_div(nsec, 1000000);
  39. return -nsec;
  40. }
  41. do_div(nsec, 1000000);
  42. return nsec;
  43. }
  44. static unsigned long nsec_low(unsigned long long nsec)
  45. {
  46. if ((long long)nsec < 0)
  47. nsec = -nsec;
  48. return do_div(nsec, 1000000);
  49. }
  50. #define SPLIT_NS(x) nsec_high(x), nsec_low(x)
  51. #ifdef CONFIG_FAIR_GROUP_SCHED
  52. static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg)
  53. {
  54. struct sched_entity *se = tg->se[cpu];
  55. #define P(F) \
  56. SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)F)
  57. #define PN(F) \
  58. SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)F))
  59. if (!se)
  60. return;
  61. PN(se->exec_start);
  62. PN(se->vruntime);
  63. PN(se->sum_exec_runtime);
  64. #ifdef CONFIG_SCHEDSTATS
  65. if (schedstat_enabled()) {
  66. PN(se->statistics.wait_start);
  67. PN(se->statistics.sleep_start);
  68. PN(se->statistics.block_start);
  69. PN(se->statistics.sleep_max);
  70. PN(se->statistics.block_max);
  71. PN(se->statistics.exec_max);
  72. PN(se->statistics.slice_max);
  73. PN(se->statistics.wait_max);
  74. PN(se->statistics.wait_sum);
  75. P(se->statistics.wait_count);
  76. }
  77. #endif
  78. P(se->load.weight);
  79. #ifdef CONFIG_SMP
  80. P(se->avg.load_avg);
  81. P(se->avg.util_avg);
  82. #endif
  83. #undef PN
  84. #undef P
  85. }
  86. #endif
  87. #ifdef CONFIG_CGROUP_SCHED
  88. static char group_path[PATH_MAX];
  89. static char *task_group_path(struct task_group *tg)
  90. {
  91. if (autogroup_path(tg, group_path, PATH_MAX))
  92. return group_path;
  93. return cgroup_path(tg->css.cgroup, group_path, PATH_MAX);
  94. }
  95. #endif
  96. static void
  97. print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
  98. {
  99. if (rq->curr == p)
  100. SEQ_printf(m, "R");
  101. else
  102. SEQ_printf(m, " ");
  103. SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ",
  104. p->comm, task_pid_nr(p),
  105. SPLIT_NS(p->se.vruntime),
  106. (long long)(p->nvcsw + p->nivcsw),
  107. p->prio);
  108. #ifdef CONFIG_SCHEDSTATS
  109. if (schedstat_enabled()) {
  110. SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld",
  111. SPLIT_NS(p->se.statistics.wait_sum),
  112. SPLIT_NS(p->se.sum_exec_runtime),
  113. SPLIT_NS(p->se.statistics.sum_sleep_runtime));
  114. }
  115. #else
  116. SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld",
  117. 0LL, 0L,
  118. SPLIT_NS(p->se.sum_exec_runtime),
  119. 0LL, 0L);
  120. #endif
  121. #ifdef CONFIG_NUMA_BALANCING
  122. SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
  123. #endif
  124. #ifdef CONFIG_CGROUP_SCHED
  125. SEQ_printf(m, " %s", task_group_path(task_group(p)));
  126. #endif
  127. SEQ_printf(m, "\n");
  128. }
  129. static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
  130. {
  131. struct task_struct *g, *p;
  132. SEQ_printf(m,
  133. "\nrunnable tasks:\n"
  134. " task PID tree-key switches prio"
  135. " wait-time sum-exec sum-sleep\n"
  136. "------------------------------------------------------"
  137. "----------------------------------------------------\n");
  138. rcu_read_lock();
  139. for_each_process_thread(g, p) {
  140. if (task_cpu(p) != rq_cpu)
  141. continue;
  142. print_task(m, rq, p);
  143. }
  144. rcu_read_unlock();
  145. }
  146. void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
  147. {
  148. s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1,
  149. spread, rq0_min_vruntime, spread0;
  150. struct rq *rq = cpu_rq(cpu);
  151. struct sched_entity *last;
  152. unsigned long flags;
  153. #ifdef CONFIG_FAIR_GROUP_SCHED
  154. SEQ_printf(m, "\ncfs_rq[%d]:%s\n", cpu, task_group_path(cfs_rq->tg));
  155. #else
  156. SEQ_printf(m, "\ncfs_rq[%d]:\n", cpu);
  157. #endif
  158. SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "exec_clock",
  159. SPLIT_NS(cfs_rq->exec_clock));
  160. raw_spin_lock_irqsave(&rq->lock, flags);
  161. if (cfs_rq->rb_leftmost)
  162. MIN_vruntime = (__pick_first_entity(cfs_rq))->vruntime;
  163. last = __pick_last_entity(cfs_rq);
  164. if (last)
  165. max_vruntime = last->vruntime;
  166. min_vruntime = cfs_rq->min_vruntime;
  167. rq0_min_vruntime = cpu_rq(0)->cfs.min_vruntime;
  168. raw_spin_unlock_irqrestore(&rq->lock, flags);
  169. SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "MIN_vruntime",
  170. SPLIT_NS(MIN_vruntime));
  171. SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "min_vruntime",
  172. SPLIT_NS(min_vruntime));
  173. SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "max_vruntime",
  174. SPLIT_NS(max_vruntime));
  175. spread = max_vruntime - MIN_vruntime;
  176. SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread",
  177. SPLIT_NS(spread));
  178. spread0 = min_vruntime - rq0_min_vruntime;
  179. SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread0",
  180. SPLIT_NS(spread0));
  181. SEQ_printf(m, " .%-30s: %d\n", "nr_spread_over",
  182. cfs_rq->nr_spread_over);
  183. SEQ_printf(m, " .%-30s: %d\n", "nr_running", cfs_rq->nr_running);
  184. SEQ_printf(m, " .%-30s: %ld\n", "load", cfs_rq->load.weight);
  185. #ifdef CONFIG_SMP
  186. SEQ_printf(m, " .%-30s: %lu\n", "load_avg",
  187. cfs_rq->avg.load_avg);
  188. SEQ_printf(m, " .%-30s: %lu\n", "runnable_load_avg",
  189. cfs_rq->runnable_load_avg);
  190. SEQ_printf(m, " .%-30s: %lu\n", "util_avg",
  191. cfs_rq->avg.util_avg);
  192. SEQ_printf(m, " .%-30s: %ld\n", "removed_load_avg",
  193. atomic_long_read(&cfs_rq->removed_load_avg));
  194. SEQ_printf(m, " .%-30s: %ld\n", "removed_util_avg",
  195. atomic_long_read(&cfs_rq->removed_util_avg));
  196. #ifdef CONFIG_FAIR_GROUP_SCHED
  197. SEQ_printf(m, " .%-30s: %lu\n", "tg_load_avg_contrib",
  198. cfs_rq->tg_load_avg_contrib);
  199. SEQ_printf(m, " .%-30s: %ld\n", "tg_load_avg",
  200. atomic_long_read(&cfs_rq->tg->load_avg));
  201. #endif
  202. #endif
  203. #ifdef CONFIG_CFS_BANDWIDTH
  204. SEQ_printf(m, " .%-30s: %d\n", "throttled",
  205. cfs_rq->throttled);
  206. SEQ_printf(m, " .%-30s: %d\n", "throttle_count",
  207. cfs_rq->throttle_count);
  208. #endif
  209. #ifdef CONFIG_FAIR_GROUP_SCHED
  210. print_cfs_group_stats(m, cpu, cfs_rq->tg);
  211. #endif
  212. }
  213. void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)
  214. {
  215. #ifdef CONFIG_RT_GROUP_SCHED
  216. SEQ_printf(m, "\nrt_rq[%d]:%s\n", cpu, task_group_path(rt_rq->tg));
  217. #else
  218. SEQ_printf(m, "\nrt_rq[%d]:\n", cpu);
  219. #endif
  220. #define P(x) \
  221. SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rt_rq->x))
  222. #define PN(x) \
  223. SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rt_rq->x))
  224. P(rt_nr_running);
  225. P(rt_throttled);
  226. PN(rt_time);
  227. PN(rt_runtime);
  228. #undef PN
  229. #undef P
  230. }
  231. void print_dl_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq)
  232. {
  233. SEQ_printf(m, "\ndl_rq[%d]:\n", cpu);
  234. SEQ_printf(m, " .%-30s: %ld\n", "dl_nr_running", dl_rq->dl_nr_running);
  235. }
  236. extern __read_mostly int sched_clock_running;
  237. static void print_cpu(struct seq_file *m, int cpu)
  238. {
  239. struct rq *rq = cpu_rq(cpu);
  240. unsigned long flags;
  241. #ifdef CONFIG_X86
  242. {
  243. unsigned int freq = cpu_khz ? : 1;
  244. SEQ_printf(m, "cpu#%d, %u.%03u MHz\n",
  245. cpu, freq / 1000, (freq % 1000));
  246. }
  247. #else
  248. SEQ_printf(m, "cpu#%d\n", cpu);
  249. #endif
  250. #define P(x) \
  251. do { \
  252. if (sizeof(rq->x) == 4) \
  253. SEQ_printf(m, " .%-30s: %ld\n", #x, (long)(rq->x)); \
  254. else \
  255. SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rq->x));\
  256. } while (0)
  257. #define PN(x) \
  258. SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rq->x))
  259. P(nr_running);
  260. SEQ_printf(m, " .%-30s: %lu\n", "load",
  261. rq->load.weight);
  262. P(nr_switches);
  263. P(nr_load_updates);
  264. P(nr_uninterruptible);
  265. PN(next_balance);
  266. SEQ_printf(m, " .%-30s: %ld\n", "curr->pid", (long)(task_pid_nr(rq->curr)));
  267. PN(clock);
  268. PN(clock_task);
  269. P(cpu_load[0]);
  270. P(cpu_load[1]);
  271. P(cpu_load[2]);
  272. P(cpu_load[3]);
  273. P(cpu_load[4]);
  274. #undef P
  275. #undef PN
  276. #ifdef CONFIG_SCHEDSTATS
  277. #define P(n) SEQ_printf(m, " .%-30s: %d\n", #n, rq->n);
  278. #define P64(n) SEQ_printf(m, " .%-30s: %Ld\n", #n, rq->n);
  279. #ifdef CONFIG_SMP
  280. P64(avg_idle);
  281. P64(max_idle_balance_cost);
  282. #endif
  283. if (schedstat_enabled()) {
  284. P(yld_count);
  285. P(sched_count);
  286. P(sched_goidle);
  287. P(ttwu_count);
  288. P(ttwu_local);
  289. }
  290. #undef P
  291. #undef P64
  292. #endif
  293. spin_lock_irqsave(&sched_debug_lock, flags);
  294. print_cfs_stats(m, cpu);
  295. print_rt_stats(m, cpu);
  296. print_dl_stats(m, cpu);
  297. print_rq(m, rq, cpu);
  298. spin_unlock_irqrestore(&sched_debug_lock, flags);
  299. SEQ_printf(m, "\n");
  300. }
  301. static const char *sched_tunable_scaling_names[] = {
  302. "none",
  303. "logaritmic",
  304. "linear"
  305. };
  306. static void sched_debug_header(struct seq_file *m)
  307. {
  308. u64 ktime, sched_clk, cpu_clk;
  309. unsigned long flags;
  310. local_irq_save(flags);
  311. ktime = ktime_to_ns(ktime_get());
  312. sched_clk = sched_clock();
  313. cpu_clk = local_clock();
  314. local_irq_restore(flags);
  315. SEQ_printf(m, "Sched Debug Version: v0.11, %s %.*s\n",
  316. init_utsname()->release,
  317. (int)strcspn(init_utsname()->version, " "),
  318. init_utsname()->version);
  319. #define P(x) \
  320. SEQ_printf(m, "%-40s: %Ld\n", #x, (long long)(x))
  321. #define PN(x) \
  322. SEQ_printf(m, "%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
  323. PN(ktime);
  324. PN(sched_clk);
  325. PN(cpu_clk);
  326. P(jiffies);
  327. #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
  328. P(sched_clock_stable());
  329. #endif
  330. #undef PN
  331. #undef P
  332. SEQ_printf(m, "\n");
  333. SEQ_printf(m, "sysctl_sched\n");
  334. #define P(x) \
  335. SEQ_printf(m, " .%-40s: %Ld\n", #x, (long long)(x))
  336. #define PN(x) \
  337. SEQ_printf(m, " .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
  338. PN(sysctl_sched_latency);
  339. PN(sysctl_sched_min_granularity);
  340. PN(sysctl_sched_wakeup_granularity);
  341. P(sysctl_sched_child_runs_first);
  342. P(sysctl_sched_features);
  343. #undef PN
  344. #undef P
  345. SEQ_printf(m, " .%-40s: %d (%s)\n",
  346. "sysctl_sched_tunable_scaling",
  347. sysctl_sched_tunable_scaling,
  348. sched_tunable_scaling_names[sysctl_sched_tunable_scaling]);
  349. SEQ_printf(m, "\n");
  350. }
  351. static int sched_debug_show(struct seq_file *m, void *v)
  352. {
  353. int cpu = (unsigned long)(v - 2);
  354. if (cpu != -1)
  355. print_cpu(m, cpu);
  356. else
  357. sched_debug_header(m);
  358. return 0;
  359. }
  360. void sysrq_sched_debug_show(void)
  361. {
  362. int cpu;
  363. sched_debug_header(NULL);
  364. for_each_online_cpu(cpu)
  365. print_cpu(NULL, cpu);
  366. }
  367. /*
  368. * This itererator needs some explanation.
  369. * It returns 1 for the header position.
  370. * This means 2 is cpu 0.
  371. * In a hotplugged system some cpus, including cpu 0, may be missing so we have
  372. * to use cpumask_* to iterate over the cpus.
  373. */
  374. static void *sched_debug_start(struct seq_file *file, loff_t *offset)
  375. {
  376. unsigned long n = *offset;
  377. if (n == 0)
  378. return (void *) 1;
  379. n--;
  380. if (n > 0)
  381. n = cpumask_next(n - 1, cpu_online_mask);
  382. else
  383. n = cpumask_first(cpu_online_mask);
  384. *offset = n + 1;
  385. if (n < nr_cpu_ids)
  386. return (void *)(unsigned long)(n + 2);
  387. return NULL;
  388. }
  389. static void *sched_debug_next(struct seq_file *file, void *data, loff_t *offset)
  390. {
  391. (*offset)++;
  392. return sched_debug_start(file, offset);
  393. }
  394. static void sched_debug_stop(struct seq_file *file, void *data)
  395. {
  396. }
  397. static const struct seq_operations sched_debug_sops = {
  398. .start = sched_debug_start,
  399. .next = sched_debug_next,
  400. .stop = sched_debug_stop,
  401. .show = sched_debug_show,
  402. };
  403. static int sched_debug_release(struct inode *inode, struct file *file)
  404. {
  405. seq_release(inode, file);
  406. return 0;
  407. }
  408. static int sched_debug_open(struct inode *inode, struct file *filp)
  409. {
  410. int ret = 0;
  411. ret = seq_open(filp, &sched_debug_sops);
  412. return ret;
  413. }
  414. static const struct file_operations sched_debug_fops = {
  415. .open = sched_debug_open,
  416. .read = seq_read,
  417. .llseek = seq_lseek,
  418. .release = sched_debug_release,
  419. };
  420. static int __init init_sched_debug_procfs(void)
  421. {
  422. struct proc_dir_entry *pe;
  423. pe = proc_create("sched_debug", 0444, NULL, &sched_debug_fops);
  424. if (!pe)
  425. return -ENOMEM;
  426. return 0;
  427. }
  428. __initcall(init_sched_debug_procfs);
  429. #define __P(F) \
  430. SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)F)
  431. #define P(F) \
  432. SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)p->F)
  433. #define __PN(F) \
  434. SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F))
  435. #define PN(F) \
  436. SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F))
  437. #ifdef CONFIG_NUMA_BALANCING
  438. void print_numa_stats(struct seq_file *m, int node, unsigned long tsf,
  439. unsigned long tpf, unsigned long gsf, unsigned long gpf)
  440. {
  441. SEQ_printf(m, "numa_faults node=%d ", node);
  442. SEQ_printf(m, "task_private=%lu task_shared=%lu ", tsf, tpf);
  443. SEQ_printf(m, "group_private=%lu group_shared=%lu\n", gsf, gpf);
  444. }
  445. #endif
  446. static void sched_show_numa(struct task_struct *p, struct seq_file *m)
  447. {
  448. #ifdef CONFIG_NUMA_BALANCING
  449. struct mempolicy *pol;
  450. if (p->mm)
  451. P(mm->numa_scan_seq);
  452. task_lock(p);
  453. pol = p->mempolicy;
  454. if (pol && !(pol->flags & MPOL_F_MORON))
  455. pol = NULL;
  456. mpol_get(pol);
  457. task_unlock(p);
  458. P(numa_pages_migrated);
  459. P(numa_preferred_nid);
  460. P(total_numa_faults);
  461. SEQ_printf(m, "current_node=%d, numa_group_id=%d\n",
  462. task_node(p), task_numa_group_id(p));
  463. show_numa_stats(p, m);
  464. mpol_put(pol);
  465. #endif
  466. }
  467. void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
  468. {
  469. unsigned long nr_switches;
  470. SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, task_pid_nr(p),
  471. get_nr_threads(p));
  472. SEQ_printf(m,
  473. "---------------------------------------------------------"
  474. "----------\n");
  475. #define __P(F) \
  476. SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)F)
  477. #define P(F) \
  478. SEQ_printf(m, "%-45s:%21Ld\n", #F, (long long)p->F)
  479. #define __PN(F) \
  480. SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F))
  481. #define PN(F) \
  482. SEQ_printf(m, "%-45s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F))
  483. PN(se.exec_start);
  484. PN(se.vruntime);
  485. PN(se.sum_exec_runtime);
  486. nr_switches = p->nvcsw + p->nivcsw;
  487. #ifdef CONFIG_SCHEDSTATS
  488. P(se.nr_migrations);
  489. if (schedstat_enabled()) {
  490. u64 avg_atom, avg_per_cpu;
  491. PN(se.statistics.sum_sleep_runtime);
  492. PN(se.statistics.wait_start);
  493. PN(se.statistics.sleep_start);
  494. PN(se.statistics.block_start);
  495. PN(se.statistics.sleep_max);
  496. PN(se.statistics.block_max);
  497. PN(se.statistics.exec_max);
  498. PN(se.statistics.slice_max);
  499. PN(se.statistics.wait_max);
  500. PN(se.statistics.wait_sum);
  501. P(se.statistics.wait_count);
  502. PN(se.statistics.iowait_sum);
  503. P(se.statistics.iowait_count);
  504. P(se.statistics.nr_migrations_cold);
  505. P(se.statistics.nr_failed_migrations_affine);
  506. P(se.statistics.nr_failed_migrations_running);
  507. P(se.statistics.nr_failed_migrations_hot);
  508. P(se.statistics.nr_forced_migrations);
  509. P(se.statistics.nr_wakeups);
  510. P(se.statistics.nr_wakeups_sync);
  511. P(se.statistics.nr_wakeups_migrate);
  512. P(se.statistics.nr_wakeups_local);
  513. P(se.statistics.nr_wakeups_remote);
  514. P(se.statistics.nr_wakeups_affine);
  515. P(se.statistics.nr_wakeups_affine_attempts);
  516. P(se.statistics.nr_wakeups_passive);
  517. P(se.statistics.nr_wakeups_idle);
  518. avg_atom = p->se.sum_exec_runtime;
  519. if (nr_switches)
  520. avg_atom = div64_ul(avg_atom, nr_switches);
  521. else
  522. avg_atom = -1LL;
  523. avg_per_cpu = p->se.sum_exec_runtime;
  524. if (p->se.nr_migrations) {
  525. avg_per_cpu = div64_u64(avg_per_cpu,
  526. p->se.nr_migrations);
  527. } else {
  528. avg_per_cpu = -1LL;
  529. }
  530. __PN(avg_atom);
  531. __PN(avg_per_cpu);
  532. }
  533. #endif
  534. __P(nr_switches);
  535. SEQ_printf(m, "%-45s:%21Ld\n",
  536. "nr_voluntary_switches", (long long)p->nvcsw);
  537. SEQ_printf(m, "%-45s:%21Ld\n",
  538. "nr_involuntary_switches", (long long)p->nivcsw);
  539. P(se.load.weight);
  540. #ifdef CONFIG_SMP
  541. P(se.avg.load_sum);
  542. P(se.avg.util_sum);
  543. P(se.avg.load_avg);
  544. P(se.avg.util_avg);
  545. P(se.avg.last_update_time);
  546. #endif
  547. P(policy);
  548. P(prio);
  549. #undef PN
  550. #undef __PN
  551. #undef P
  552. #undef __P
  553. {
  554. unsigned int this_cpu = raw_smp_processor_id();
  555. u64 t0, t1;
  556. t0 = cpu_clock(this_cpu);
  557. t1 = cpu_clock(this_cpu);
  558. SEQ_printf(m, "%-45s:%21Ld\n",
  559. "clock-delta", (long long)(t1-t0));
  560. }
  561. sched_show_numa(p, m);
  562. }
  563. void proc_sched_set_task(struct task_struct *p)
  564. {
  565. #ifdef CONFIG_SCHEDSTATS
  566. memset(&p->se.statistics, 0, sizeof(p->se.statistics));
  567. #endif
  568. }