STRUCT HRTIMER_CPU_BASE(9)
π struct hrtimer_cpu_base(9) π
okay so bestie, welcome to the Kernel API Manual page for struct hrtimer_cpu_base β this is the per cpu clock bases, and it's honestly such a main character struct. it holds all the timer bookkeeping for one CPU, and every field is here so we're going through all of them, no skipping, periodt β¨
π NAME π
struct hrtimer_cpu_base β the per cpu clock bases πΈ
β¨ SYNOPSIS β¨
struct hrtimer_cpu_base {
raw_spinlock_t lock;
unsigned int cpu;
unsigned int active_bases;
u32 clock_was_set_seq;
bool hres_active;
bool deferred_rearm;
bool deferred_needs_update;
bool hang_detected;
bool softirq_activated;
bool online;
#ifdef CONFIG_HIGH_RES_TIMERS;
unsigned int nr_events;
unsigned short nr_retries;
unsigned short nr_hangs;
unsigned int max_hang_time;
#endif;
#ifdef CONFIG_PREEMPT_RT;
spinlock_t softirq_expiry_lock;
atomic_t timer_waiters;
#endif;
ktime_t expires_next;
struct hrtimer *next_timer;
ktime_t softirq_expires_next;
struct hrtimer *softirq_next_timer;
ktime_t deferred_expires_next;
struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
call_single_data_t csd;
};
quick vibe check on that: some of these fields only exist when CONFIG_HIGH_RES_TIMERS or CONFIG_PREEMPT_RT is on, so likeβ¦ conditional queen behavior π
π«Ά Members (the good part, fr fr)
lockβ the lock protecting the base and the associated clock bases and timers. it's giving bodyguard energy π₯cpuβ the cpu number. literally just which CPU this whole thing belongs to.active_basesβ a Bitfield to mark bases with active timers πclock_was_set_seqβ Sequence counter of clock was set events. yes it counts them, someone has to πhres_activeβ State of high resolution mode. the high-res situation report β¨deferred_rearmβ A deferred rearm is pending. it's on the to-do list bestie πdeferred_needs_updateβ The deferred rearm must re-evaluate the first timer. like, it has to go back and re-check the first one π«Άhang_detectedβ The last hrtimer interrupt detected a hang. red flag, literally πsoftirq_activatedβ displays, if the softirq is raised - update of softirq related settings is not required then. so if this is up, no update needed, we can chill πonlineβ CPU is online from an hrtimers point of view π¦nr_eventsβ Total number of hrtimer interrupt eventsnr_retriesβ Total number of hrtimer interrupt retriesnr_hangsβ Total number of hrtimer interrupt hangsmax_hang_timeβ Maximum time spent inhrtimer_interruptsoftirq_expiry_lockβ Lock which is taken while softirq based hrtimer are expiredtimer_waitersβ Ahrtimer_cancelwaiters for the timer callback to finish. they're waiting, be patient π₯Ίexpires_nextβ Absolute time of the next event, is required for remote hrtimer enqueue; it is the total first expiry time (hard and soft hrtimer are taken into account). both flavors accounted for, no cap βnext_timerβ Pointer to the first expiring timersoftirq_expires_nextβ Time to check, if soft queues needs also to be expiredsoftirq_next_timerβ Pointer to the first expiring softirq based timerdeferred_expires_nextβ Cached expires next value for deferred rearm πclock_baseβ Array of clock bases for this cpu π
side note:csd(acall_single_data_t) is in the struct up in the synopsis, but this page doesn't give it a member writeup β so i'm not out here making one up π the fournr_*/max_hang_timefields above are theCONFIG_HIGH_RES_TIMERSones, andsoftirq_expiry_lock+timer_waitersare theCONFIG_PREEMPT_RTones. iykyk π
π Note π
β οΈnext_timeris just an optimization for__remove_hrtimer. Do not dereference the pointer because it is not reliable on cross cpu removals. seriously bestie, hands off the pointer on this one π
π SEE ALSO π
- Kernel file
./include/linux/hrtimer_bases.h struct hrtimer_clock_base(9)
okay that's the whole page, you ate that π this came to you from ./include/linux, dated October 2026, and it's the struct hrtimer_cpu_base(9) page β go forth and schedule responsibly, mwah ππ§
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms