timer_stats.txt 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. timer_stats - timer usage statistics
  2. ------------------------------------
  3. timer_stats is a debugging facility to make the timer (ab)usage in a Linux
  4. system visible to kernel and userspace developers. If enabled in the config
  5. but not used it has almost zero runtime overhead, and a relatively small
  6. data structure overhead. Even if collection is enabled runtime all the
  7. locking is per-CPU and lookup is hashed.
  8. timer_stats should be used by kernel and userspace developers to verify that
  9. their code does not make unduly use of timers. This helps to avoid unnecessary
  10. wakeups, which should be avoided to optimize power consumption.
  11. It can be enabled by CONFIG_TIMER_STATS in the "Kernel hacking" configuration
  12. section.
  13. timer_stats collects information about the timer events which are fired in a
  14. Linux system over a sample period:
  15. - the pid of the task(process) which initialized the timer
  16. - the name of the process which initialized the timer
  17. - the function where the timer was initialized
  18. - the callback function which is associated to the timer
  19. - the number of events (callbacks)
  20. timer_stats adds an entry to /proc: /proc/timer_stats
  21. This entry is used to control the statistics functionality and to read out the
  22. sampled information.
  23. The timer_stats functionality is inactive on bootup.
  24. To activate a sample period issue:
  25. # echo 1 >/proc/timer_stats
  26. To stop a sample period issue:
  27. # echo 0 >/proc/timer_stats
  28. The statistics can be retrieved by:
  29. # cat /proc/timer_stats
  30. While sampling is enabled, each readout from /proc/timer_stats will see
  31. newly updated statistics. Once sampling is disabled, the sampled information
  32. is kept until a new sample period is started. This allows multiple readouts.
  33. Sample output of /proc/timer_stats:
  34. Timerstats sample period: 3.888770 s
  35. 12, 0 swapper hrtimer_stop_sched_tick (hrtimer_sched_tick)
  36. 15, 1 swapper hcd_submit_urb (rh_timer_func)
  37. 4, 959 kedac schedule_timeout (process_timeout)
  38. 1, 0 swapper page_writeback_init (wb_timer_fn)
  39. 28, 0 swapper hrtimer_stop_sched_tick (hrtimer_sched_tick)
  40. 22, 2948 IRQ 4 tty_flip_buffer_push (delayed_work_timer_fn)
  41. 3, 3100 bash schedule_timeout (process_timeout)
  42. 1, 1 swapper queue_delayed_work_on (delayed_work_timer_fn)
  43. 1, 1 swapper queue_delayed_work_on (delayed_work_timer_fn)
  44. 1, 1 swapper neigh_table_init_no_netlink (neigh_periodic_timer)
  45. 1, 2292 ip __netdev_watchdog_up (dev_watchdog)
  46. 1, 23 events/1 do_cache_clean (delayed_work_timer_fn)
  47. 90 total events, 30.0 events/sec
  48. The first column is the number of events, the second column the pid, the third
  49. column is the name of the process. The forth column shows the function which
  50. initialized the timer and in parenthesis the callback function which was
  51. executed on expiry.
  52. Thomas, Ingo
  53. Added flag to indicate 'deferrable timer' in /proc/timer_stats. A deferrable
  54. timer will appear as follows
  55. 10D, 1 swapper queue_delayed_work_on (delayed_work_timer_fn)