Linux 4.14-rc6
[linux-2.6-block.git] / kernel / time / tick-sched.h
CommitLineData
c1797baf
TG
1#ifndef _TICK_SCHED_H
2#define _TICK_SCHED_H
3
4#include <linux/hrtimer.h>
5
7270d11c
TG
6enum tick_device_mode {
7 TICKDEV_MODE_PERIODIC,
8 TICKDEV_MODE_ONESHOT,
9};
10
11struct tick_device {
12 struct clock_event_device *evtdev;
13 enum tick_device_mode mode;
14};
15
c1797baf
TG
16enum tick_nohz_mode {
17 NOHZ_MODE_INACTIVE,
18 NOHZ_MODE_LOWRES,
19 NOHZ_MODE_HIGHRES,
20};
21
22/**
23 * struct tick_sched - sched tick emulation and no idle tick control/stats
24 * @sched_timer: hrtimer to schedule the periodic tick in high
25 * resolution mode
26 * @last_tick: Store the last tick expiry time when the tick
27 * timer is modified for nohz sleeps. This is necessary
28 * to resume the tick timer operation in the timeline
29 * when the CPU returns from nohz sleep.
411fe24e 30 * @next_tick: Next tick to be fired when in dynticks mode.
c1797baf
TG
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_waketime: Time when the idle was interrupted
37 * @idle_exittime: Time when the idle state was left
38 * @idle_sleeptime: Sum of the time slept in idle with sched tick stopped
39 * @iowait_sleeptime: Sum of the time slept in idle with sched tick stopped, with IO outstanding
40 * @sleep_length: Duration of the current idle sleep
41 * @do_timer_lst: CPU was the last one doing do_timer before going idle
42 */
43struct tick_sched {
44 struct hrtimer sched_timer;
45 unsigned long check_clocks;
46 enum tick_nohz_mode nohz_mode;
47 ktime_t last_tick;
411fe24e 48 ktime_t next_tick;
c1797baf
TG
49 int inidle;
50 int tick_stopped;
51 unsigned long idle_jiffies;
52 unsigned long idle_calls;
53 unsigned long idle_sleeps;
54 int idle_active;
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 ktime_t sleep_length;
61 unsigned long last_jiffies;
c1ad348b 62 u64 next_timer;
c1797baf
TG
63 ktime_t idle_expires;
64 int do_timer_last;
f009a7a7 65 atomic_t tick_dep_mask;
c1797baf
TG
66};
67
68extern struct tick_sched *tick_get_tick_sched(int cpu);
69
70extern void tick_setup_sched_timer(void);
71#if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
72extern void tick_cancel_sched_timer(int cpu);
73#else
74static inline void tick_cancel_sched_timer(int cpu) { }
75#endif
76
f32dd117
TG
77#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
78extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
79#else
80static inline int
81__tick_broadcast_oneshot_control(enum tick_broadcast_state state)
82{
83 return -EBUSY;
84}
85#endif
86
c1797baf 87#endif