debug.c 15 KB

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