]> www.infradead.org Git - users/jedix/linux-maple.git/commit
hrtimer: Use and report correct timerslack values for realtime tasks
authorFelix Moessbauer <felix.moessbauer@siemens.com>
Wed, 14 Aug 2024 12:10:32 +0000 (14:10 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 23 Aug 2024 18:13:02 +0000 (20:13 +0200)
commited4fb6d7ef68111bb539283561953e5c6e9a6e38
treed50d171c56904dbbae69764adc07f4f33301bc91
parent330dd6d9c0fce69718b53ca0bc4f2e3920f7f600
hrtimer: Use and report correct timerslack values for realtime tasks

The timerslack_ns setting is used to specify how much the hardware
timers should be delayed, to potentially dispatch multiple timers in a
single interrupt. This is a performance optimization. Timers of
realtime tasks (having a realtime scheduling policy) should not be
delayed.

This logic was inconsitently applied to the hrtimers, leading to delays
of realtime tasks which used timed waits for events (e.g. condition
variables). Due to the downstream override of the slack for rt tasks,
the procfs reported incorrect (non-zero) timerslack_ns values.

This is changed by setting the timer_slack_ns task attribute to 0 for
all tasks with a rt policy. By that, downstream users do not need to
specially handle rt tasks (w.r.t. the slack), and the procfs entry
shows the correct value of "0". Setting non-zero slack values (either
via procfs or PR_SET_TIMERSLACK) on tasks with a rt policy is ignored,
as stated in "man 2 PR_SET_TIMERSLACK":

  Timer slack is not applied to threads that are scheduled under a
  real-time scheduling policy (see sched_setscheduler(2)).

The special handling of timerslack on rt tasks in downstream users
is removed as well.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240814121032.368444-2-felix.moessbauer@siemens.com
fs/proc/base.c
fs/select.c
kernel/sched/syscalls.c
kernel/sys.c
kernel/time/hrtimer.c