Merge tag 'powerpc-5.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[linux/fpc-iii.git] / kernel / time / tick-sched.h
blob4fb06527cf64fe72da2ddcf550c8cd6de96aa4bc
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _TICK_SCHED_H
3 #define _TICK_SCHED_H
5 #include <linux/hrtimer.h>
7 enum tick_device_mode {
8 TICKDEV_MODE_PERIODIC,
9 TICKDEV_MODE_ONESHOT,
12 struct tick_device {
13 struct clock_event_device *evtdev;
14 enum tick_device_mode mode;
17 enum tick_nohz_mode {
18 NOHZ_MODE_INACTIVE,
19 NOHZ_MODE_LOWRES,
20 NOHZ_MODE_HIGHRES,
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 * @check_clocks: Notification mechanism about clocksource changes
28 * @nohz_mode: Mode - one state of tick_nohz_mode
29 * @inidle: Indicator that the CPU is in the tick idle mode
30 * @tick_stopped: Indicator that the idle tick has been stopped
31 * @idle_active: Indicator that the CPU is actively in the tick idle mode;
32 * it is resetted during irq handling phases.
33 * @do_timer_lst: CPU was the last one doing do_timer before going idle
34 * @got_idle_tick: Tick timer function has run with @inidle set
35 * @last_tick: Store the last tick expiry time when the tick
36 * timer is modified for nohz sleeps. This is necessary
37 * to resume the tick timer operation in the timeline
38 * when the CPU returns from nohz sleep.
39 * @next_tick: Next tick to be fired when in dynticks mode.
40 * @idle_jiffies: jiffies at the entry to idle for idle time accounting
41 * @idle_calls: Total number of idle calls
42 * @idle_sleeps: Number of idle calls, where the sched tick was stopped
43 * @idle_entrytime: Time when the idle call was entered
44 * @idle_waketime: Time when the idle was interrupted
45 * @idle_exittime: Time when the idle state was left
46 * @idle_sleeptime: Sum of the time slept in idle with sched tick stopped
47 * @iowait_sleeptime: Sum of the time slept in idle with sched tick stopped, with IO outstanding
48 * @timer_expires: Anticipated timer expiration time (in case sched tick is stopped)
49 * @timer_expires_base: Base time clock monotonic for @timer_expires
50 * @next_timer: Expiry time of next expiring timer for debugging purpose only
51 * @tick_dep_mask: Tick dependency mask - is set, if someone needs the tick
53 struct tick_sched {
54 struct hrtimer sched_timer;
55 unsigned long check_clocks;
56 enum tick_nohz_mode nohz_mode;
58 unsigned int inidle : 1;
59 unsigned int tick_stopped : 1;
60 unsigned int idle_active : 1;
61 unsigned int do_timer_last : 1;
62 unsigned int got_idle_tick : 1;
64 ktime_t last_tick;
65 ktime_t next_tick;
66 unsigned long idle_jiffies;
67 unsigned long idle_calls;
68 unsigned long idle_sleeps;
69 ktime_t idle_entrytime;
70 ktime_t idle_waketime;
71 ktime_t idle_exittime;
72 ktime_t idle_sleeptime;
73 ktime_t iowait_sleeptime;
74 unsigned long last_jiffies;
75 u64 timer_expires;
76 u64 timer_expires_base;
77 u64 next_timer;
78 ktime_t idle_expires;
79 atomic_t tick_dep_mask;
82 extern struct tick_sched *tick_get_tick_sched(int cpu);
84 extern void tick_setup_sched_timer(void);
85 #if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
86 extern void tick_cancel_sched_timer(int cpu);
87 #else
88 static inline void tick_cancel_sched_timer(int cpu) { }
89 #endif
91 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
92 extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
93 #else
94 static inline int
95 __tick_broadcast_oneshot_control(enum tick_broadcast_state state)
97 return -EBUSY;
99 #endif
101 #endif