* [PATCH] timers: Check timer_pending() before reading bucket index
@ 2026-08-28 14:53 Liang Hao
2026-09-05 20:35 ` Thomas Gleixner
0 siblings, 1 reply; 3+ messages 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] 3+ messages in thread
* Re: [PATCH] timers: Check timer_pending() before reading bucket index
2026-08-28 14:53 [PATCH] timers: Check timer_pending() before reading bucket index Liang Hao
@ 2026-09-05 20:35 ` Thomas Gleixner
2026-09-06 1:49 ` Liang Hao
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2026-09-05 20:35 UTC (permalink / raw)
To: Liang Hao, Anna-Maria Behnsen, Frederic Weisbecker
Cc: linux-kernel, Liang Hao
On Fri, Aug 28 2026 at 22:53, Liang Hao wrote:
> Only read the cached wheel index when the timer is still queued.
> No functional change.
Which problem is actually solved by this?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] timers: Check timer_pending() before reading bucket index
2026-09-05 20:35 ` Thomas Gleixner
@ 2026-09-06 1:49 ` Liang Hao
0 siblings, 0 replies; 3+ messages in thread
From: Liang Hao @ 2026-09-06 1:49 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: Anna-Maria Behnsen, Frederic Weisbecker, linux-kernel
On Sat, Sep 05 2026 at 22:35, Thomas Gleixner wrote:
> Which problem is actually solved by this?
None that shows up as a bug. The index is never used when the
timer is not queued; I only reordered the checks. I'll drop it.
Thanks,
Liang Hao
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-06 1:49 UTC | newest]
Thread overview: 3+ messages (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
2026-09-05 20:35 ` Thomas Gleixner
2026-09-06 1:49 ` 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®