mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Weiss <thnkslprpt@gmail.com>
To: Anna-Maria Behnsen <anna-maria@linutronix.de>
Cc: Frederic Weisbecker <frederic@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] timers/itimer: Preserve nonzero remaining time for active timers
Date: Mon,  2 Nov 2026 09:01:49 +0200	[thread overview]
Message-ID: <20261102070148.1064849-2-thnkslprpt@gmail.com> (raw)

itimer_get_remtime() preserves positive remainders below one
microsecond, but struct timeval only stores whole microseconds.
So, for example, the conversion to tv_usec truncates a 500 ns
remainder to zero, causing getitimer(ITIMER_REAL) to report an
active timer as disarmed.

Clamp active remainders below one microsecond to one microsecond
so they remain nonzero after conversion.

Fixes: 2ff678b8da64 ("[PATCH] hrtimer: switch itimers to hrtimer")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 kernel/time/itimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/itimer.c b/kernel/time/itimer.c
index 03a32dffc56c..a472a4f8babb 100644
--- a/kernel/time/itimer.c
+++ b/kernel/time/itimer.c
@@ -36,7 +36,7 @@ static struct timespec64 itimer_get_remtime(struct hrtimer *timer)
 	 * then we return 0 - which is correct.
 	 */
 	if (hrtimer_active(timer)) {
-		if (rem <= 0)
+		if (rem < NSEC_PER_USEC)
 			rem = NSEC_PER_USEC;
 	} else
 		rem = 0;

base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
-- 
2.43.0


             reply	other threads:[~2026-11-02  7:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  7:01 Avi Weiss [this message]
2026-11-02 22:15 ` Frederic Weisbecker

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=20261102070148.1064849-2-thnkslprpt@gmail.com \
    --to=thnkslprpt@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®