Linux Audio

Check our new training course

Yocto distribution development and maintenance

Need a Yocto distribution for your embedded project?
Loading...
v6.2
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef _TICK_SCHED_H
  3#define _TICK_SCHED_H
  4
  5#include <linux/hrtimer.h>
  6
  7enum tick_device_mode {
  8	TICKDEV_MODE_PERIODIC,
  9	TICKDEV_MODE_ONESHOT,
 10};
 11
 12struct tick_device {
 13	struct clock_event_device *evtdev;
 14	enum tick_device_mode mode;
 15};
 16
 17enum 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 * @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 reset 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
 52 * @last_tick_jiffies:	Value of jiffies seen on last tick
 53 * @stalled_jiffies:	Number of stalled jiffies detected across ticks
 54 */
 55struct tick_sched {
 56	struct hrtimer			sched_timer;
 57	unsigned long			check_clocks;
 58	enum tick_nohz_mode		nohz_mode;
 59
 60	unsigned int			inidle		: 1;
 61	unsigned int			tick_stopped	: 1;
 62	unsigned int			idle_active	: 1;
 63	unsigned int			do_timer_last	: 1;
 64	unsigned int			got_idle_tick	: 1;
 65
 66	ktime_t				last_tick;
 67	ktime_t				next_tick;
 68	unsigned long			idle_jiffies;
 69	unsigned long			idle_calls;
 70	unsigned long			idle_sleeps;
 71	ktime_t				idle_entrytime;
 72	ktime_t				idle_waketime;
 73	ktime_t				idle_exittime;
 74	ktime_t				idle_sleeptime;
 75	ktime_t				iowait_sleeptime;
 76	unsigned long			last_jiffies;
 77	u64				timer_expires;
 78	u64				timer_expires_base;
 79	u64				next_timer;
 80	ktime_t				idle_expires;
 81	atomic_t			tick_dep_mask;
 82	unsigned long			last_tick_jiffies;
 83	unsigned int			stalled_jiffies;
 84};
 85
 86extern struct tick_sched *tick_get_tick_sched(int cpu);
 87
 88extern void tick_setup_sched_timer(void);
 89#if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
 90extern void tick_cancel_sched_timer(int cpu);
 91#else
 92static inline void tick_cancel_sched_timer(int cpu) { }
 93#endif
 94
 95#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
 96extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
 97#else
 98static inline int
 99__tick_broadcast_oneshot_control(enum tick_broadcast_state state)
100{
101	return -EBUSY;
102}
103#endif
104
105#endif
v4.17
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef _TICK_SCHED_H
 3#define _TICK_SCHED_H
 4
 5#include <linux/hrtimer.h>
 6
 7enum tick_device_mode {
 8	TICKDEV_MODE_PERIODIC,
 9	TICKDEV_MODE_ONESHOT,
10};
11
12struct tick_device {
13	struct clock_event_device *evtdev;
14	enum tick_device_mode mode;
15};
16
17enum 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.
31 * @next_tick:		Next tick to be fired when in dynticks mode.
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
41 * @timer_expires:	Anticipated timer expiration time (in case sched tick is stopped)
42 * @timer_expires_base:	Base time clock monotonic for @timer_expires
43 * @do_timer_lst:	CPU was the last one doing do_timer before going idle
44 * @got_idle_tick:	Tick timer function has run with @inidle set
 
 
45 */
46struct tick_sched {
47	struct hrtimer			sched_timer;
48	unsigned long			check_clocks;
49	enum tick_nohz_mode		nohz_mode;
50
51	unsigned int			inidle		: 1;
52	unsigned int			tick_stopped	: 1;
53	unsigned int			idle_active	: 1;
54	unsigned int			do_timer_last	: 1;
55	unsigned int			got_idle_tick	: 1;
56
57	ktime_t				last_tick;
58	ktime_t				next_tick;
59	unsigned long			idle_jiffies;
60	unsigned long			idle_calls;
61	unsigned long			idle_sleeps;
62	ktime_t				idle_entrytime;
63	ktime_t				idle_waketime;
64	ktime_t				idle_exittime;
65	ktime_t				idle_sleeptime;
66	ktime_t				iowait_sleeptime;
67	unsigned long			last_jiffies;
68	u64				timer_expires;
69	u64				timer_expires_base;
70	u64				next_timer;
71	ktime_t				idle_expires;
72	atomic_t			tick_dep_mask;
 
 
73};
74
75extern struct tick_sched *tick_get_tick_sched(int cpu);
76
77extern void tick_setup_sched_timer(void);
78#if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
79extern void tick_cancel_sched_timer(int cpu);
80#else
81static inline void tick_cancel_sched_timer(int cpu) { }
82#endif
83
84#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
85extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
86#else
87static inline int
88__tick_broadcast_oneshot_control(enum tick_broadcast_state state)
89{
90	return -EBUSY;
91}
92#endif
93
94#endif