Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_HRTIMER_DEFS_H
3#define _LINUX_HRTIMER_DEFS_H
4
5#include <linux/ktime.h>
6#include <linux/timerqueue.h>
7#include <linux/seqlock.h>
8
9#ifdef CONFIG_64BIT
10# define __hrtimer_clock_base_align ____cacheline_aligned
11#else
12# define __hrtimer_clock_base_align
13#endif
14
15/**
16 * struct hrtimer_clock_base - the timer base for a specific clock
17 * @cpu_base: per cpu clock base
18 * @index: clock type index for per_cpu support when moving a
19 * timer to a base on another cpu.
20 * @clockid: clock id for per_cpu support
21 * @seq: seqcount around __run_hrtimer
22 * @expires_next: Absolute time of the next event in this clock base
23 * @running: pointer to the currently running hrtimer
24 * @active: red black tree root node for the active timers
25 * @offset: offset of this clock to the monotonic base
26 */
27struct hrtimer_clock_base {
28 struct hrtimer_cpu_base *cpu_base;
29 const unsigned int index;
30 const clockid_t clockid;
31 seqcount_raw_spinlock_t seq;
32 ktime_t expires_next;
33 struct hrtimer *running;
34 struct timerqueue_linked_head active;
35 ktime_t offset;
36} __hrtimer_clock_base_align;
37
38enum hrtimer_base_type {
39 HRTIMER_BASE_MONOTONIC,
40 HRTIMER_BASE_REALTIME,
41 HRTIMER_BASE_BOOTTIME,
42 HRTIMER_BASE_TAI,
43 HRTIMER_BASE_MONOTONIC_SOFT,
44 HRTIMER_BASE_REALTIME_SOFT,
45 HRTIMER_BASE_BOOTTIME_SOFT,
46 HRTIMER_BASE_TAI_SOFT,
47 HRTIMER_MAX_CLOCK_BASES
48};
49
50/**
51 * struct hrtimer_cpu_base - the per cpu clock bases
52 * @lock: lock protecting the base and associated clock bases and timers
53 * @cpu: cpu number
54 * @active_bases: Bitfield to mark bases with active timers
55 * @clock_was_set_seq: Sequence counter of clock was set events
56 * @hres_active: State of high resolution mode
57 * @deferred_rearm: A deferred rearm is pending
58 * @deferred_needs_update: The deferred rearm must re-evaluate the first timer
59 * @hang_detected: The last hrtimer interrupt detected a hang
60 * @softirq_activated: displays, if the softirq is raised - update of softirq
61 * related settings is not required then.
62 * @nr_events: Total number of hrtimer interrupt events
63 * @nr_retries: Total number of hrtimer interrupt retries
64 * @nr_hangs: Total number of hrtimer interrupt hangs
65 * @max_hang_time: Maximum time spent in hrtimer_interrupt
66 * @softirq_expiry_lock: Lock which is taken while softirq based hrtimer are expired
67 * @online: CPU is online from an hrtimers point of view
68 * @timer_waiters: A hrtimer_cancel() waiters for the timer callback to finish.
69 * @expires_next: Absolute time of the next event, is required for remote
70 * hrtimer enqueue; it is the total first expiry time (hard
71 * and soft hrtimer are taken into account)
72 * @next_timer: Pointer to the first expiring timer
73 * @softirq_expires_next: Time to check, if soft queues needs also to be expired
74 * @softirq_next_timer: Pointer to the first expiring softirq based timer
75 * @deferred_expires_next: Cached expires next value for deferred rearm
76 * @clock_base: Array of clock bases for this cpu
77 *
78 * Note: next_timer is just an optimization for __remove_hrtimer().
79 * Do not dereference the pointer because it is not reliable on
80 * cross cpu removals.
81 */
82struct hrtimer_cpu_base {
83 raw_spinlock_t lock;
84 unsigned int cpu;
85 unsigned int active_bases;
86 unsigned int clock_was_set_seq;
87 bool hres_active;
88 bool deferred_rearm;
89 bool deferred_needs_update;
90 bool hang_detected;
91 bool softirq_activated;
92 bool online;
93#ifdef CONFIG_HIGH_RES_TIMERS
94 unsigned int nr_events;
95 unsigned short nr_retries;
96 unsigned short nr_hangs;
97 unsigned int max_hang_time;
98#endif
99#ifdef CONFIG_PREEMPT_RT
100 spinlock_t softirq_expiry_lock;
101 atomic_t timer_waiters;
102#endif
103 ktime_t expires_next;
104 struct hrtimer *next_timer;
105 ktime_t softirq_expires_next;
106 struct hrtimer *softirq_next_timer;
107 ktime_t deferred_expires_next;
108 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
109 call_single_data_t csd;
110} ____cacheline_aligned;
111
112
113#endif