From: Frederic Weisbecker <frederic@kernel.org>
To: Avi Weiss <thnkslprpt@gmail.com>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>,
Thomas Gleixner <tglx@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] timers/itimer: Preserve nonzero remaining time for active timers
Date: Mon, 2 Nov 2026 23:15:30 +0100 [thread overview]
Message-ID: <aukLgmXkPBneoMe8@pavilion.home> (raw)
In-Reply-To: <20261102070148.1064849-2-thnkslprpt@gmail.com>
Le Mon, Nov 02, 2026 at 09:01:49AM +0200, Avi Weiss a écrit :
> 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;
Right, though at this point it can race with the hrtimer at any point.
But it makes sense to have.
Thanks.
> } else
> rem = 0;
>
> base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
> --
> 2.43.0
>
--
Frederic Weisbecker
SUSE Labs
prev parent reply other threads:[~2026-11-02 22:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 7:01 Avi Weiss
2026-11-02 22:15 ` Frederic Weisbecker [this message]
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=aukLgmXkPBneoMe8@pavilion.home \
--to=frederic@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=thnkslprpt@gmail.com \
/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®