tick-sched.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. };
  59. extern struct tick_sched *tick_get_tick_sched(int cpu);
  60. extern void tick_setup_sched_timer(void);
  61. #if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
  62. extern void tick_cancel_sched_timer(int cpu);
  63. #else
  64. static inline void tick_cancel_sched_timer(int cpu) { }
  65. #endif
  66. #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
  67. extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
  68. #else
  69. static inline int
  70. __tick_broadcast_oneshot_control(enum tick_broadcast_state state)
  71. {
  72. return -EBUSY;
  73. }
  74. #endif
  75. #endif