mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Weiss <thnkslprpt@gmail.com>
To: anna-maria@linutronix.de
Cc: frederic@kernel.org, tglx@kernel.org, mingo@kernel.org,
	linux-kernel@vger.kernel.org, Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH] hrtimer: Refresh softirq deadline after clock changes in low-res mode
Date: Sun,  1 Nov 2026 19:23:44 +0200	[thread overview]
Message-ID: <20261101172344.426489-1-thnkslprpt@gmail.com> (raw)

In periodic low-resolution mode, hrtimer_run_queues() updates the clock
base offsets at each tick but does not refresh softirq_expires_next.
When CLOCK_REALTIME is moved forward, an expired soft hrtimer can
therefore remain pending until the old monotonic deadline is reached.

Reevaluate the next expiry when hrtimer_update_base() observes a new
clock-was-set sequence, before checking whether to raise HRTIMER_SOFTIRQ.

Fixes: 5da70160462e ("hrtimer: Implement support for softirq based hrtimers")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 kernel/time/hrtimer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 17dd38a6cee7..5d1df371e931 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -2289,6 +2289,7 @@ void hrtimer_run_queues(void)
 	struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);
 	unsigned long flags;
 	ktime_t now;
+	unsigned int seq;
 
 	if (hrtimer_hres_active(cpu_base))
 		return;
@@ -2306,7 +2307,10 @@ void hrtimer_run_queues(void)
 	}
 
 	raw_spin_lock_irqsave(&cpu_base->lock, flags);
+	seq = cpu_base->clock_was_set_seq;
 	now = hrtimer_update_base(cpu_base);
+	if (seq != cpu_base->clock_was_set_seq)
+		hrtimer_update_next_event(cpu_base);
 
 	if (!ktime_before(now, cpu_base->softirq_expires_next)) {
 		cpu_base->softirq_expires_next = KTIME_MAX;

base-commit: cbbddb6b08cc9900a87cccaa9b22bbe06aa4f50a
-- 
2.53.0


                 reply	other threads:[~2026-11-01 17:24 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=20261101172344.426489-1-thnkslprpt@gmail.com \
    --to=thnkslprpt@gmail.com \
    --cc=anna-maria@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@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®