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 * @running: pointer to the currently running hrtimer 23 * @active: red black tree root node for the active timers 24 * @offset: offset of this clock to the monotonic base 25 */ 26 struct hrtimer_clock_base { 27 struct hrtimer_cpu_base *cpu_base; 28 unsigned int index; 29 clockid_t clockid; 30 seqcount_raw_spinlock_t seq; 31 struct hrtimer *running; 32 struct timerqueue_head active; 33 ktime_t offset; 34 } __hrtimer_clock_base_align; 35 36 enum hrtimer_base_type { 37 HRTIMER_BASE_MONOTONIC, 38 HRTIMER_BASE_REALTIME, 39 HRTIMER_BASE_BOOTTIME, 40 HRTIMER_BASE_TAI, 41 HRTIMER_BASE_MONOTONIC_SOFT, 42 HRTIMER_BASE_REALTIME_SOFT, 43 HRTIMER_BASE_BOOTTIME_SOFT, 44 HRTIMER_BASE_TAI_SOFT, 45 HRTIMER_MAX_CLOCK_BASES, 46 }; 47 48 /** 49 * struct hrtimer_cpu_base - the per cpu clock bases 50 * @lock: lock protecting the base and associated clock bases 51 * and timers 52 * @cpu: cpu number 53 * @active_bases: Bitfield to mark bases with active timers 54 * @clock_was_set_seq: Sequence counter of clock was set events 55 * @hres_active: State of high resolution mode 56 * @in_hrtirq: hrtimer_interrupt() is currently executing 57 * @hang_detected: The last hrtimer interrupt detected a hang 58 * @softirq_activated: displays, if the softirq is raised - update of softirq 59 * related settings is not required then. 60 * @nr_events: Total number of hrtimer interrupt events 61 * @nr_retries: Total number of hrtimer interrupt retries 62 * @nr_hangs: Total number of hrtimer interrupt hangs 63 * @max_hang_time: Maximum time spent in hrtimer_interrupt 64 * @softirq_expiry_lock: Lock which is taken while softirq based hrtimer are 65 * expired 66 * @online: CPU is online from an hrtimers point of view 67 * @timer_waiters: A hrtimer_cancel() invocation waits for the timer 68 * 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 * @clock_base: array of clock bases for this cpu 76 * 77 * Note: next_timer is just an optimization for __remove_hrtimer(). 78 * Do not dereference the pointer because it is not reliable on 79 * cross cpu removals. 80 */ 81 struct hrtimer_cpu_base { 82 raw_spinlock_t lock; 83 unsigned int cpu; 84 unsigned int active_bases; 85 unsigned int clock_was_set_seq; 86 unsigned int hres_active : 1, 87 in_hrtirq : 1, 88 hang_detected : 1, 89 softirq_activated : 1, 90 online : 1; 91 #ifdef CONFIG_HIGH_RES_TIMERS 92 unsigned int nr_events; 93 unsigned short nr_retries; 94 unsigned short nr_hangs; 95 unsigned int max_hang_time; 96 #endif 97 #ifdef CONFIG_PREEMPT_RT 98 spinlock_t softirq_expiry_lock; 99 atomic_t timer_waiters; 100 #endif 101 ktime_t expires_next; 102 struct hrtimer *next_timer; 103 ktime_t softirq_expires_next; 104 struct hrtimer *softirq_next_timer; 105 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; 106 call_single_data_t csd; 107 } ____cacheline_aligned; 108 109 110 #endif 111