tick-sched.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef _TICK_SCHED_H
  2. #define _TICK_SCHED_H
  3. #include <linux/hrtimer.h>
  4. enum tick_device_mode {
  5. TICKDEV_MODE_PERIODIC,
  6. TICKDEV_MODE_ONESHOT,
  7. };
  8. struct tick_device {
  9. struct clock_event_device *evtdev;
  10. enum tick_device_mode mode;
  11. };
  12. enum tick_nohz_mode {
  13. NOHZ_MODE_INACTIVE,
  14. NOHZ_MODE_LOWRES,
  15. NOHZ_MODE_HIGHRES,
  16. };
  17. /**
  18. * struct tick_sched - sched tick emulation and no idle tick control/stats
  19. * @sched_timer: hrtimer to schedule the periodic tick in high
  20. * resolution mode
  21. * @last_tick: Store the last tick expiry time when the tick
  22. * timer is modified for nohz sleeps. This is necessary
  23. * to resume the tick timer operation in the timeline
  24. * when the CPU returns from nohz sleep.
  25. * @tick_stopped: Indicator that the idle tick has been stopped
  26. * @idle_jiffies: jiffies at the entry to idle for idle time accounting
  27. * @idle_calls: Total number of idle calls
  28. * @idle_sleeps: Number of idle calls, where the sched tick was stopped
  29. * @idle_entrytime: Time when the idle call was entered
  30. * @idle_waketime: Time when the idle was interrupted
  31. * @idle_exittime: Time when the idle state was left
  32. * @idle_sleeptime: Sum of the time slept in idle with sched tick stopped
  33. * @iowait_sleeptime: Sum of the time slept in idle with sched tick stopped, with IO outstanding
  34. * @sleep_length: Duration of the current idle sleep
  35. * @do_timer_lst: CPU was the last one doing do_timer before going idle
  36. */
  37. struct tick_sched {
  38. struct hrtimer sched_timer;
  39. unsigned long check_clocks;
  40. enum tick_nohz_mode nohz_mode;
  41. ktime_t last_tick;
  42. int inidle;
  43. int tick_stopped;
  44. unsigned long idle_jiffies;
  45. unsigned long idle_calls;
  46. unsigned long idle_sleeps;
  47. int idle_active;
  48. ktime_t idle_entrytime;
  49. ktime_t idle_waketime;
  50. ktime_t idle_exittime;
  51. ktime_t idle_sleeptime;
  52. ktime_t iowait_sleeptime;
  53. ktime_t sleep_length;
  54. unsigned long last_jiffies;
  55. u64 next_timer;
  56. ktime_t idle_expires;
  57. int do_timer_last;
  58. atomic_t tick_dep_mask;
  59. };
  60. extern struct tick_sched *tick_get_tick_sched(int cpu);
  61. extern void tick_setup_sched_timer(void);
  62. #if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
  63. extern void tick_cancel_sched_timer(int cpu);
  64. #else
  65. static inline void tick_cancel_sched_timer(int cpu) { }
  66. #endif
  67. #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
  68. extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
  69. #else
  70. static inline int
  71. __tick_broadcast_oneshot_control(enum tick_broadcast_state state)
  72. {
  73. return -EBUSY;
  74. }
  75. #endif
  76. #endif