tick.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* linux/include/linux/tick.h
  2. *
  3. * This file contains the structure definitions for tick related functions
  4. *
  5. */
  6. #ifndef _LINUX_TICK_H
  7. #define _LINUX_TICK_H
  8. #include <linux/clockchips.h>
  9. #ifdef CONFIG_GENERIC_CLOCKEVENTS
  10. enum tick_device_mode {
  11. TICKDEV_MODE_PERIODIC,
  12. TICKDEV_MODE_ONESHOT,
  13. };
  14. struct tick_device {
  15. struct clock_event_device *evtdev;
  16. enum tick_device_mode mode;
  17. };
  18. enum tick_nohz_mode {
  19. NOHZ_MODE_INACTIVE,
  20. NOHZ_MODE_LOWRES,
  21. NOHZ_MODE_HIGHRES,
  22. };
  23. /**
  24. * struct tick_sched - sched tick emulation and no idle tick control/stats
  25. * @sched_timer: hrtimer to schedule the periodic tick in high
  26. * resolution mode
  27. * @idle_tick: Store the last idle tick expiry time when the tick
  28. * timer is modified for idle sleeps. This is necessary
  29. * to resume the tick timer operation in the timeline
  30. * when the CPU returns from idle
  31. * @tick_stopped: Indicator that the idle tick has been stopped
  32. * @idle_jiffies: jiffies at the entry to idle for idle time accounting
  33. * @idle_calls: Total number of idle calls
  34. * @idle_sleeps: Number of idle calls, where the sched tick was stopped
  35. * @idle_entrytime: Time when the idle call was entered
  36. * @idle_sleeptime: Sum of the time slept in idle with sched tick stopped
  37. */
  38. struct tick_sched {
  39. struct hrtimer sched_timer;
  40. unsigned long check_clocks;
  41. enum tick_nohz_mode nohz_mode;
  42. ktime_t idle_tick;
  43. int tick_stopped;
  44. unsigned long idle_jiffies;
  45. unsigned long idle_calls;
  46. unsigned long idle_sleeps;
  47. ktime_t idle_entrytime;
  48. ktime_t idle_sleeptime;
  49. unsigned long last_jiffies;
  50. unsigned long next_jiffies;
  51. ktime_t idle_expires;
  52. };
  53. extern void __init tick_init(void);
  54. extern int tick_is_oneshot_available(void);
  55. # ifdef CONFIG_HIGH_RES_TIMERS
  56. extern int tick_init_highres(void);
  57. extern int tick_program_event(ktime_t expires, int force);
  58. extern void tick_setup_sched_timer(void);
  59. extern void tick_cancel_sched_timer(int cpu);
  60. # else
  61. static inline void tick_cancel_sched_timer(int cpu) { }
  62. # endif /* HIGHRES */
  63. # ifdef CONFIG_TICK_ONESHOT
  64. extern void tick_clock_notify(void);
  65. extern int tick_check_oneshot_change(int allow_nohz);
  66. extern struct tick_sched *tick_get_tick_sched(int cpu);
  67. # else
  68. static inline void tick_clock_notify(void) { }
  69. static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
  70. # endif
  71. #else /* CONFIG_GENERIC_CLOCKEVENTS */
  72. static inline void tick_init(void) { }
  73. static inline void tick_cancel_sched_timer(int cpu) { }
  74. static inline void tick_clock_notify(void) { }
  75. static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
  76. #endif /* !CONFIG_GENERIC_CLOCKEVENTS */
  77. # ifdef CONFIG_NO_HZ
  78. extern void tick_nohz_stop_sched_tick(void);
  79. extern void tick_nohz_restart_sched_tick(void);
  80. extern void tick_nohz_update_jiffies(void);
  81. # else
  82. static inline void tick_nohz_stop_sched_tick(void) { }
  83. static inline void tick_nohz_restart_sched_tick(void) { }
  84. static inline void tick_nohz_update_jiffies(void) { }
  85. # endif /* !NO_HZ */
  86. #endif