Linux Audio

Check our new training course

Embedded Linux training

Mar 31-Apr 8, 2025
Register
Loading...
v4.10.11
 
 1#ifndef _TICK_SCHED_H
 2#define _TICK_SCHED_H
 3
 4#include <linux/hrtimer.h>
 5
 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
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.
30 * @tick_stopped:	Indicator that the idle tick has been stopped
31 * @idle_jiffies:	jiffies at the entry to idle for idle time accounting
 
 
 
 
 
 
 
 
32 * @idle_calls:		Total number of idle calls
33 * @idle_sleeps:	Number of idle calls, where the sched tick was stopped
34 * @idle_entrytime:	Time when the idle call was entered
35 * @idle_waketime:	Time when the idle was interrupted
36 * @idle_exittime:	Time when the idle state was left
37 * @idle_sleeptime:	Sum of the time slept in idle with sched tick stopped
38 * @iowait_sleeptime:	Sum of the time slept in idle with sched tick stopped, with IO outstanding
39 * @sleep_length:	Duration of the current idle sleep
40 * @do_timer_lst:	CPU was the last one doing do_timer before going idle
41 */
42struct tick_sched {
 
 
 
 
 
 
 
 
 
 
 
 
43	struct hrtimer			sched_timer;
44	unsigned long			check_clocks;
45	enum tick_nohz_mode		nohz_mode;
46	ktime_t				last_tick;
47	int				inidle;
48	int				tick_stopped;
49	unsigned long			idle_jiffies;
 
 
 
 
 
 
 
 
 
 
 
 
 
50	unsigned long			idle_calls;
51	unsigned long			idle_sleeps;
52	int				idle_active;
53	ktime_t				idle_entrytime;
54	ktime_t				idle_waketime;
55	ktime_t				idle_exittime;
56	ktime_t				idle_sleeptime;
57	ktime_t				iowait_sleeptime;
58	ktime_t				sleep_length;
59	unsigned long			last_jiffies;
60	u64				next_timer;
61	ktime_t				idle_expires;
62	int				do_timer_last;
63	atomic_t			tick_dep_mask;
 
 
 
64};
65
66extern struct tick_sched *tick_get_tick_sched(int cpu);
67
68extern void tick_setup_sched_timer(void);
69#if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
70extern void tick_cancel_sched_timer(int cpu);
71#else
72static inline void tick_cancel_sched_timer(int cpu) { }
73#endif
74
75#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
76extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
77#else
78static inline int
79__tick_broadcast_oneshot_control(enum tick_broadcast_state state)
80{
81	return -EBUSY;
82}
83#endif
84
85#endif
v6.8
  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 *
 26 * @inidle:		Indicator that the CPU is in the tick idle mode
 27 * @tick_stopped:	Indicator that the idle tick has been stopped
 28 * @idle_active:	Indicator that the CPU is actively in the tick idle mode;
 29 *			it is reset during irq handling phases.
 30 * @do_timer_last:	CPU was the last one doing do_timer before going idle
 31 * @got_idle_tick:	Tick timer function has run with @inidle set
 32 * @stalled_jiffies:	Number of stalled jiffies detected across ticks
 33 * @last_tick_jiffies:	Value of jiffies seen on last tick
 34 * @sched_timer:	hrtimer to schedule the periodic tick in high
 35 *			resolution mode
 36 * @last_tick:		Store the last tick expiry time when the tick
 37 *			timer is modified for nohz sleeps. This is necessary
 38 *			to resume the tick timer operation in the timeline
 39 *			when the CPU returns from nohz sleep.
 40 * @next_tick:		Next tick to be fired when in dynticks mode.
 41 * @idle_jiffies:	jiffies at the entry to idle for idle time accounting
 42 * @idle_waketime:	Time when the idle was interrupted
 43 * @idle_entrytime:	Time when the idle call was entered
 44 * @nohz_mode:		Mode - one state of tick_nohz_mode
 45 * @last_jiffies:	Base jiffies snapshot when next event was last computed
 46 * @timer_expires_base:	Base time clock monotonic for @timer_expires
 47 * @timer_expires:	Anticipated timer expiration time (in case sched tick is stopped)
 48 * @next_timer:		Expiry time of next expiring timer for debugging purpose only
 49 * @idle_expires:	Next tick in idle, for debugging purpose only
 50 * @idle_calls:		Total number of idle calls
 51 * @idle_sleeps:	Number of idle calls, where the sched tick was stopped
 
 
 52 * @idle_exittime:	Time when the idle state was left
 53 * @idle_sleeptime:	Sum of the time slept in idle with sched tick stopped
 54 * @iowait_sleeptime:	Sum of the time slept in idle with sched tick stopped, with IO outstanding
 55 * @tick_dep_mask:	Tick dependency mask - is set, if someone needs the tick
 56 * @check_clocks:	Notification mechanism about clocksource changes
 57 */
 58struct tick_sched {
 59	/* Common flags */
 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	/* Tick handling: jiffies stall check */
 67	unsigned int			stalled_jiffies;
 68	unsigned long			last_tick_jiffies;
 69
 70	/* Tick handling */
 71	struct hrtimer			sched_timer;
 
 
 72	ktime_t				last_tick;
 73	ktime_t				next_tick;
 
 74	unsigned long			idle_jiffies;
 75	ktime_t				idle_waketime;
 76
 77	/* Idle entry */
 78	seqcount_t			idle_sleeptime_seq;
 79	ktime_t				idle_entrytime;
 80
 81	/* Tick stop */
 82	enum tick_nohz_mode		nohz_mode;
 83	unsigned long			last_jiffies;
 84	u64				timer_expires_base;
 85	u64				timer_expires;
 86	u64				next_timer;
 87	ktime_t				idle_expires;
 88	unsigned long			idle_calls;
 89	unsigned long			idle_sleeps;
 90
 91	/* Idle exit */
 
 92	ktime_t				idle_exittime;
 93	ktime_t				idle_sleeptime;
 94	ktime_t				iowait_sleeptime;
 95
 96	/* Full dynticks handling */
 
 
 
 97	atomic_t			tick_dep_mask;
 98
 99	/* Clocksource changes */
100	unsigned long			check_clocks;
101};
102
103extern struct tick_sched *tick_get_tick_sched(int cpu);
104
105extern void tick_setup_sched_timer(void);
106#if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS
107extern void tick_cancel_sched_timer(int cpu);
108#else
109static inline void tick_cancel_sched_timer(int cpu) { }
110#endif
111
112#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
113extern int __tick_broadcast_oneshot_control(enum tick_broadcast_state state);
114#else
115static inline int
116__tick_broadcast_oneshot_control(enum tick_broadcast_state state)
117{
118	return -EBUSY;
119}
120#endif
121
122#endif