tick-sched.h 2.7 KB

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