tick-sched.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. * @check_clocks: Notification mechanism about clocksource changes
  23. * @nohz_mode: Mode - one state of tick_nohz_mode
  24. * @inidle: Indicator that the CPU is in the tick idle mode
  25. * @tick_stopped: Indicator that the idle tick has been stopped
  26. * @idle_active: Indicator that the CPU is actively in the tick idle mode;
  27. * it is reset during irq handling phases.
  28. * @do_timer_lst: CPU was the last one doing do_timer before going idle
  29. * @got_idle_tick: Tick timer function has run with @inidle set
  30. * @last_tick: Store the last tick expiry time when the tick
  31. * timer is modified for nohz sleeps. This is necessary
  32. * to resume the tick timer operation in the timeline
  33. * when the CPU returns from nohz sleep.
  34. * @next_tick: Next tick to be fired when in dynticks mode.
  35. * @idle_jiffies: jiffies at the entry to idle for idle time accounting
  36. * @idle_calls: Total number of idle calls
  37. * @idle_sleeps: Number of idle calls, where the sched tick was stopped
  38. * @idle_entrytime: Time when the idle call was entered
  39. * @idle_waketime: Time when the idle was interrupted
  40. * @idle_exittime: Time when the idle state was left
  41. * @idle_sleeptime: Sum of the time slept in idle with sched tick stopped
  42. * @iowait_sleeptime: Sum of the time slept in idle with sched tick stopped, with IO outstanding
  43. * @timer_expires: Anticipated timer expiration time (in case sched tick is stopped)
  44. * @timer_expires_base: Base time clock monotonic for @timer_expires
  45. * @next_timer: Expiry time of next expiring timer for debugging purpose only
  46. * @tick_dep_mask: Tick dependency mask - is set, if someone needs the tick
  47. * @last_tick_jiffies: Value of jiffies seen on last tick
  48. * @stalled_jiffies: Number of stalled jiffies detected across ticks
  49. */
  50. struct tick_sched {
  51. struct hrtimer sched_timer;
  52. unsigned long check_clocks;
  53. enum tick_nohz_mode nohz_mode;
  54. unsigned int inidle : 1;
  55. unsigned int tick_stopped : 1;
  56. unsigned int idle_active : 1;
  57. unsigned int do_timer_last : 1;
  58. unsigned int got_idle_tick : 1;
  59. ktime_t last_tick;
  60. ktime_t next_tick;
  61. unsigned long idle_jiffies;
  62. unsigned long idle_calls;
  63. unsigned long idle_sleeps;
  64. ktime_t idle_entrytime;
  65. ktime_t idle_waketime;
  66. ktime_t idle_exittime;
  67. ktime_t idle_sleeptime;
  68. ktime_t iowait_sleeptime;
  69. unsigned long last_jiffies;
  70. u64 timer_expires;
  71. u64 timer_expires_base;
  72. u64 next_timer;
  73. ktime_t idle_expires;
  74. atomic_t tick_dep_mask;
  75. unsigned long last_tick_jiffies;
  76. unsigned int stalled_jiffies;
  77. };
  78. extern struct tick_sched *tick_get_tick_sched(int cpu);
  79. extern void tick_setup_sched_timer(void);
  80. #if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
  81. extern void tick_cancel_sched_timer(int cpu);
  82. #else
  83. static inline void tick_cancel_sched_timer(int cpu) { }
  84. #endif
  85. #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
  86. extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
  87. #else
  88. static inline int
  89. __tick_broadcast_oneshot_control(enum tick_broadcast_state state)
  90. {
  91. return -EBUSY;
  92. }
  93. #endif
  94. #endif