mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] timers: Check timer_pending() before reading bucket index
@ 2026-08-28 14:53 Liang Hao
  0 siblings, 0 replies; only message in thread
From: Liang Hao @ 2026-08-28 14:53 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner
  Cc: linux-kernel, Liang Hao

Only read the cached wheel index when the timer is still queued.
No functional change.

Signed-off-by: Liang Hao <haohlliang@gmail.com>
---
 kernel/time/timer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index ae9abf14688e..9f3b199d3075 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -897,11 +897,13 @@ static inline void detach_timer(struct timer_list *timer, bool clear_pending)
 static int detach_if_pending(struct timer_list *timer, struct timer_base *base,
 			     bool clear_pending)
 {
-	unsigned idx = timer_get_idx(timer);
+	unsigned int idx;
 
 	if (!timer_pending(timer))
 		return 0;
 
+	idx = timer_get_idx(timer);
+
 	if (hlist_is_singular_node(&timer->entry, base->vectors + idx)) {
 		__clear_bit(idx, base->pending_map);
 		base->next_expiry_recalc = true;
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-28 14:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-28 14:53 [PATCH] timers: Check timer_pending() before reading bucket index Liang Hao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®