Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

hrtimer: Add a helper to retrieve a hrtimer from its timerqueue node

The container_of() call is open-coded multiple times.

Add a helper macro.

Use container_of_const() to preserve constness.

Signed-off-by: Thomas Weißschuh (Schneider Electric) <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260311-hrtimer-cleanups-v1-12-095357392669@linutronix.de

authored by

Thomas Weißschuh (Schneider Electric) and committed by
Thomas Gleixner
88c316ff f27fc117

+5 -3
+5 -3
kernel/time/hrtimer.c
··· 534 534 for (bool done = false; !done; active &= ~(1U << idx)) \ 535 535 for (base = &cpu_base->clock_base[idx]; !done; done = true) 536 536 537 + #define hrtimer_from_timerqueue_node(_n) container_of_const(_n, struct hrtimer, node) 538 + 537 539 #if defined(CONFIG_NO_HZ_COMMON) 538 540 /* 539 541 * Same as hrtimer_bases_next_event() below, but skips the excluded timer and ··· 580 578 { 581 579 struct timerqueue_linked_node *next = timerqueue_linked_first(&base->active); 582 580 583 - return container_of(next, struct hrtimer, node); 581 + return hrtimer_from_timerqueue_node(next); 584 582 } 585 583 586 584 /* Find the base with the earliest expiry */ ··· 1962 1960 { 1963 1961 struct timerqueue_linked_node *next = timerqueue_linked_first(&base->active); 1964 1962 1965 - return next ? container_of(next, struct hrtimer, node) : NULL; 1963 + return next ? hrtimer_from_timerqueue_node(next) : NULL; 1966 1964 } 1967 1965 1968 1966 static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now, ··· 2441 2439 struct hrtimer *timer; 2442 2440 2443 2441 while ((node = timerqueue_linked_first(&old_base->active))) { 2444 - timer = container_of(node, struct hrtimer, node); 2442 + timer = hrtimer_from_timerqueue_node(node); 2445 2443 BUG_ON(hrtimer_callback_running(timer)); 2446 2444 debug_hrtimer_deactivate(timer); 2447 2445