tick-sched.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. * @got_idle_tick: Tick timer function has run with @inidle set
  40. */
  41. struct tick_sched {
  42. struct hrtimer sched_timer;
  43. unsigned long check_clocks;
  44. enum tick_nohz_mode nohz_mode;
  45. unsigned int inidle : 1;
  46. unsigned int tick_stopped : 1;
  47. unsigned int idle_active : 1;
  48. unsigned int do_timer_last : 1;
  49. unsigned int got_idle_tick : 1;
  50. ktime_t last_tick;
  51. ktime_t next_tick;
  52. unsigned long idle_jiffies;
  53. unsigned long idle_calls;
  54. unsigned long idle_sleeps;
  55. ktime_t idle_entrytime;
  56. ktime_t idle_waketime;
  57. ktime_t idle_exittime;
  58. ktime_t idle_sleeptime;
  59. ktime_t iowait_sleeptime;
  60. unsigned long last_jiffies;
  61. u64 timer_expires;
  62. u64 timer_expires_base;
  63. u64 next_timer;
  64. ktime_t idle_expires;
  65. atomic_t tick_dep_mask;
  66. };
  67. extern struct tick_sched *tick_get_tick_sched(int cpu);
  68. extern void tick_setup_sched_timer(void);
  69. #if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
  70. extern void tick_cancel_sched_timer(int cpu);
  71. #else
  72. static inline void tick_cancel_sched_timer(int cpu) { }
  73. #endif
  74. #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
  75. extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
  76. #else
  77. static inline int
  78. __tick_broadcast_oneshot_control(enum tick_broadcast_state state)
  79. {
  80. return -EBUSY;
  81. }
  82. #endif
  83. #endif