sched-stats.txt 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. Version 10 of schedstats includes support for sched_domains, which
  2. hit the mainline kernel in 2.6.7. Some counters make more sense to be
  3. per-runqueue; other to be per-domain. Note that domains (and their associated
  4. information) will only be pertinent and available on machines utilizing
  5. CONFIG_SMP.
  6. In version 10 of schedstat, there is at least one level of domain
  7. statistics for each cpu listed, and there may well be more than one
  8. domain. Domains have no particular names in this implementation, but
  9. the highest numbered one typically arbitrates balancing across all the
  10. cpus on the machine, while domain0 is the most tightly focused domain,
  11. sometimes balancing only between pairs of cpus. At this time, there
  12. are no architectures which need more than three domain levels. The first
  13. field in the domain stats is a bit map indicating which cpus are affected
  14. by that domain.
  15. These fields are counters, and only increment. Programs which make use
  16. of these will need to start with a baseline observation and then calculate
  17. the change in the counters at each subsequent observation. A perl script
  18. which does this for many of the fields is available at
  19. http://eaglet.rain.com/rick/linux/schedstat/
  20. Note that any such script will necessarily be version-specific, as the main
  21. reason to change versions is changes in the output format. For those wishing
  22. to write their own scripts, the fields are described here.
  23. CPU statistics
  24. --------------
  25. cpu<N> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  26. NOTE: In the sched_yield() statistics, the active queue is considered empty
  27. if it has only one process in it, since obviously the process calling
  28. sched_yield() is that process.
  29. First four fields are sched_yield() statistics:
  30. 1) # of times both the active and the expired queue were empty
  31. 2) # of times just the active queue was empty
  32. 3) # of times just the expired queue was empty
  33. 4) # of times sched_yield() was called
  34. Next four are schedule() statistics:
  35. 5) # of times the active queue had at least one other process on it
  36. 6) # of times we switched to the expired queue and reused it
  37. 7) # of times schedule() was called
  38. 8) # of times schedule() left the processor idle
  39. Next four are active_load_balance() statistics:
  40. 9) # of times active_load_balance() was called
  41. 10) # of times active_load_balance() caused this cpu to gain a task
  42. 11) # of times active_load_balance() caused this cpu to lose a task
  43. 12) # of times active_load_balance() tried to move a task and failed
  44. Next three are try_to_wake_up() statistics:
  45. 13) # of times try_to_wake_up() was called
  46. 14) # of times try_to_wake_up() successfully moved the awakening task
  47. 15) # of times try_to_wake_up() attempted to move the awakening task
  48. Next two are wake_up_new_task() statistics:
  49. 16) # of times wake_up_new_task() was called
  50. 17) # of times wake_up_new_task() successfully moved the new task
  51. Next one is a sched_migrate_task() statistic:
  52. 18) # of times sched_migrate_task() was called
  53. Next one is a sched_balance_exec() statistic:
  54. 19) # of times sched_balance_exec() was called
  55. Next three are statistics describing scheduling latency:
  56. 20) sum of all time spent running by tasks on this processor (in ms)
  57. 21) sum of all time spent waiting to run by tasks on this processor (in ms)
  58. 22) # of tasks (not necessarily unique) given to the processor
  59. The last six are statistics dealing with pull_task():
  60. 23) # of times pull_task() moved a task to this cpu when newly idle
  61. 24) # of times pull_task() stole a task from this cpu when another cpu
  62. was newly idle
  63. 25) # of times pull_task() moved a task to this cpu when idle
  64. 26) # of times pull_task() stole a task from this cpu when another cpu
  65. was idle
  66. 27) # of times pull_task() moved a task to this cpu when busy
  67. 28) # of times pull_task() stole a task from this cpu when another cpu
  68. was busy
  69. Domain statistics
  70. -----------------
  71. One of these is produced per domain for each cpu described. (Note that if
  72. CONFIG_SMP is not defined, *no* domains are utilized and these lines
  73. will not appear in the output.)
  74. domain<N> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  75. The first field is a bit mask indicating what cpus this domain operates over.
  76. The next fifteen are a variety of load_balance() statistics:
  77. 1) # of times in this domain load_balance() was called when the cpu
  78. was idle
  79. 2) # of times in this domain load_balance() was called when the cpu
  80. was busy
  81. 3) # of times in this domain load_balance() was called when the cpu
  82. was just becoming idle
  83. 4) # of times in this domain load_balance() tried to move one or more
  84. tasks and failed, when the cpu was idle
  85. 5) # of times in this domain load_balance() tried to move one or more
  86. tasks and failed, when the cpu was busy
  87. 6) # of times in this domain load_balance() tried to move one or more
  88. tasks and failed, when the cpu was just becoming idle
  89. 7) sum of imbalances discovered (if any) with each call to
  90. load_balance() in this domain when the cpu was idle
  91. 8) sum of imbalances discovered (if any) with each call to
  92. load_balance() in this domain when the cpu was busy
  93. 9) sum of imbalances discovered (if any) with each call to
  94. load_balance() in this domain when the cpu was just becoming idle
  95. 10) # of times in this domain load_balance() was called but did not find
  96. a busier queue while the cpu was idle
  97. 11) # of times in this domain load_balance() was called but did not find
  98. a busier queue while the cpu was busy
  99. 12) # of times in this domain load_balance() was called but did not find
  100. a busier queue while the cpu was just becoming idle
  101. 13) # of times in this domain a busier queue was found while the cpu was
  102. idle but no busier group was found
  103. 14) # of times in this domain a busier queue was found while the cpu was
  104. busy but no busier group was found
  105. 15) # of times in this domain a busier queue was found while the cpu was
  106. just becoming idle but no busier group was found
  107. Next two are sched_balance_exec() statistics:
  108. 17) # of times in this domain sched_balance_exec() successfully pushed
  109. a task to a new cpu
  110. 18) # of times in this domain sched_balance_exec() tried but failed to
  111. push a task to a new cpu
  112. Next two are try_to_wake_up() statistics:
  113. 19) # of times in this domain try_to_wake_up() tried to move a task based
  114. on affinity and cache warmth
  115. 20) # of times in this domain try_to_wake_up() tried to move a task based
  116. on load balancing
  117. /proc/<pid>/schedstat
  118. ----------------
  119. schedstats also adds a new /proc/<pid/schedstat file to include some of
  120. the same information on a per-process level. There are three fields in
  121. this file correlating to fields 20, 21, and 22 in the CPU fields, but
  122. they only apply for that process.
  123. A program could be easily written to make use of these extra fields to
  124. report on how well a particular process or set of processes is faring
  125. under the scheduler's policies. A simple version of such a program is
  126. available at
  127. http://eaglet.rain.com/rick/linux/schedstat/v10/latency.c