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