mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Liang Hao <haohlliang@gmail.com>
To: Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Frederic Weisbecker <frederic@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>
Cc: linux-kernel@vger.kernel.org, Liang Hao <haohlliang@gmail.com>
Subject: [PATCH] timers: Check timer_pending() before reading bucket index
Date: Fri, 28 Aug 2026 22:53:47 +0800	[thread overview]
Message-ID: <20260828145347.71644-1-haohlliang@gmail.com> (raw)

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)


                 reply	other threads:[~2026-08-28 14:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260828145347.71644-1-haohlliang@gmail.com \
    --to=haohlliang@gmail.com \
    --cc=anna-maria@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®