public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Felix Moessbauer <felix.moessbauer@siemens.com>,
	linux-kernel@vger.kernel.org
Cc: Frederic Weisbecker <frederic@kernel.org>,
	Anna-Maria Behnsen <anna-maria@linutronix.de>,
	jan.kiszka@siemens.com,
	Felix Moessbauer <felix.moessbauer@siemens.com>,
	stable@vger.kernel.org,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: Re: [PATCH 2/2] hrtimer: Ignore slack time for RT tasks in hrtimer_start_range_ns()
Date: Mon, 05 Aug 2024 15:05:42 +0200	[thread overview]
Message-ID: <87a5hr5dcp.ffs@tglx> (raw)
In-Reply-To: <20240805124116.21394-3-felix.moessbauer@siemens.com>

On Mon, Aug 05 2024 at 14:41, Felix Moessbauer wrote:
> RT tasks do not have any timerslack, as this induces jitter. By
> that, the timer slack is already ignored in the nanosleep family and
> schedule_hrtimeout_range() (fixed in 0c52310f2600).
>
> The hrtimer_start_range_ns function is indirectly used by glibc-2.33+
> for timed waits on condition variables. These are sometimes used in
> RT applications for realtime queue processing. At least on the
> combination of kernel 5.10 and glibc-2.31, the timed wait on condition
> variables in rt tasks was precise (no slack), however glibc-2.33
> changed the internal wait implementation, exposing the kernel bug.

That's hardly a bug. It's an oversight.

> This patch makes the timer slack consistent across all hrtimer

"This patch" ....

> programming code, by ignoring the timerslack for rt tasks also in the
> last remaining location in hrtimer_start_range_ns().
>
> Similar to 0c52310f2600, this fix should be backported as well.

This is not part of the change log.

> Cc: stable@vger.kernel.org
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
>  kernel/time/hrtimer.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
> index 2b1469f61d9c..1b26e095114d 100644
> --- a/kernel/time/hrtimer.c
> +++ b/kernel/time/hrtimer.c
> @@ -1274,7 +1274,7 @@ static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
>   * hrtimer_start_range_ns - (re)start an hrtimer
>   * @timer:	the timer to be added
>   * @tim:	expiry time
> - * @delta_ns:	"slack" range for the timer
> + * @delta_ns:	"slack" range for the timer for SCHED_OTHER tasks
>   * @mode:	timer mode: absolute (HRTIMER_MODE_ABS) or
>   *		relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED);
>   *		softirq based mode is considered for debug purpose only!
> @@ -1299,6 +1299,10 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
>  
>  	base = lock_hrtimer_base(timer, &flags);
>  
> +	/* rt-tasks do not have a timer slack for obvious reasons */
> +	if (rt_task(current))
> +		delta_ns = 0;

        task_is_realtime()

please

Thanks,

        tglx

      reply	other threads:[~2024-08-05 13:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05 12:41 [PATCH 0/2] hrtimer: More fixes for handling of timer slack of rt tasks Felix Moessbauer
2024-08-05 12:41 ` [PATCH 1/2] hrtimer: Document, that PI boosted tasks have no timer slack Felix Moessbauer
2024-08-05 13:02   ` Thomas Gleixner
2024-08-05 13:27     ` Sebastian Andrzej Siewior
2024-08-05 12:41 ` [PATCH 2/2] hrtimer: Ignore slack time for RT tasks in hrtimer_start_range_ns() Felix Moessbauer
2024-08-05 13:05   ` Thomas Gleixner [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=87a5hr5dcp.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=anna-maria@linutronix.de \
    --cc=bigeasy@linutronix.de \
    --cc=felix.moessbauer@siemens.com \
    --cc=frederic@kernel.org \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.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