* [PATCH v2][5.10, 5.15, 6.1][0/1] hrtimer: Ignore slack time for RT tasks @ 2024-02-20 12:34 Felix Moessbauer 2024-02-20 12:34 ` [PATCH v2][5.10, 5.15, 6.1][1/1] hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() Felix Moessbauer 0 siblings, 1 reply; 5+ messages in thread From: Felix Moessbauer @ 2024-02-20 12:34 UTC (permalink / raw) To: stable; +Cc: dave, tglx, bigeasy, petr.ivanov, jan.kiszka, Felix Moessbauer Changes since v1: - added upstream commit id to the commit message This suggests a fix from 6.3 for stable that fixes a nasty bug in the timing behavior of periodic RT tasks w.r.t timerslack_ns. While the documentation clearly states that the slack time is ignored for RT tasks, this is not the case for the hrtimer code. This patch fixes the issue and applies to all stable kernels. Best regards, Felix Moessbauer Siemens AG Davidlohr Bueso (1): hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() kernel/time/hrtimer.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) -- 2.39.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2][5.10, 5.15, 6.1][1/1] hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() 2024-02-20 12:34 [PATCH v2][5.10, 5.15, 6.1][0/1] hrtimer: Ignore slack time for RT tasks Felix Moessbauer @ 2024-02-20 12:34 ` Felix Moessbauer 2024-02-20 14:32 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Felix Moessbauer @ 2024-02-20 12:34 UTC (permalink / raw) To: stable; +Cc: dave, tglx, bigeasy, petr.ivanov, jan.kiszka From: Davidlohr Bueso <dave@stgolabs.net> commit 0c52310f260014d95c1310364379772cb74cf82d upstream. While in theory the timer can be triggered before expires + delta, for the cases of RT tasks they really have no business giving any lenience for extra slack time, so override any passed value by the user and always use zero for schedule_hrtimeout_range() calls. Furthermore, this is similar to what the nanosleep(2) family already does with current->timer_slack_ns. Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20230123173206.6764-3-dave@stgolabs.net --- kernel/time/hrtimer.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index ede09dda36e9..0aebb88f1c11 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2161,7 +2161,7 @@ void __init hrtimers_init(void) /** * schedule_hrtimeout_range_clock - sleep until timeout * @expires: timeout value (ktime_t) - * @delta: slack in expires timeout (ktime_t) + * @delta: slack in expires timeout (ktime_t) for SCHED_OTHER tasks * @mode: timer mode * @clock_id: timer clock to be used */ @@ -2188,6 +2188,13 @@ schedule_hrtimeout_range_clock(ktime_t *expires, u64 delta, return -EINTR; } + /* + * Override any slack passed by the user if under + * rt contraints. + */ + if (rt_task(current)) + delta = 0; + hrtimer_init_sleeper_on_stack(&t, clock_id, mode); hrtimer_set_expires_range_ns(&t.timer, *expires, delta); hrtimer_sleeper_start_expires(&t, mode); @@ -2207,7 +2214,7 @@ EXPORT_SYMBOL_GPL(schedule_hrtimeout_range_clock); /** * schedule_hrtimeout_range - sleep until timeout * @expires: timeout value (ktime_t) - * @delta: slack in expires timeout (ktime_t) + * @delta: slack in expires timeout (ktime_t) for SCHED_OTHER tasks * @mode: timer mode * * Make the current task sleep until the given expiry time has @@ -2215,7 +2222,8 @@ EXPORT_SYMBOL_GPL(schedule_hrtimeout_range_clock); * the current task state has been set (see set_current_state()). * * The @delta argument gives the kernel the freedom to schedule the - * actual wakeup to a time that is both power and performance friendly. + * actual wakeup to a time that is both power and performance friendly + * for regular (non RT/DL) tasks. * The kernel give the normal best effort behavior for "@expires+@delta", * but may decide to fire the timer earlier, but no earlier than @expires. * -- 2.39.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2][5.10, 5.15, 6.1][1/1] hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() 2024-02-20 12:34 ` [PATCH v2][5.10, 5.15, 6.1][1/1] hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() Felix Moessbauer @ 2024-02-20 14:32 ` Greg KH 2024-02-20 14:49 ` MOESSBAUER, Felix 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2024-02-20 14:32 UTC (permalink / raw) To: Felix Moessbauer; +Cc: stable, dave, tglx, bigeasy, petr.ivanov, jan.kiszka On Tue, Feb 20, 2024 at 01:34:03PM +0100, Felix Moessbauer wrote: > From: Davidlohr Bueso <dave@stgolabs.net> > > commit 0c52310f260014d95c1310364379772cb74cf82d upstream. > > While in theory the timer can be triggered before expires + delta, for the > cases of RT tasks they really have no business giving any lenience for > extra slack time, so override any passed value by the user and always use > zero for schedule_hrtimeout_range() calls. Furthermore, this is similar to > what the nanosleep(2) family already does with current->timer_slack_ns. > > Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > Link: https://lore.kernel.org/r/20230123173206.6764-3-dave@stgolabs.net You can't forward on a patch without signing off on it as well :( And this is already in the 6.1.53 release, why apply it again? confused, greg k-h ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2][5.10, 5.15, 6.1][1/1] hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() 2024-02-20 14:32 ` Greg KH @ 2024-02-20 14:49 ` MOESSBAUER, Felix 2024-02-20 14:58 ` gregkh 0 siblings, 1 reply; 5+ messages in thread From: MOESSBAUER, Felix @ 2024-02-20 14:49 UTC (permalink / raw) To: gregkh@linuxfoundation.org Cc: tglx@linutronix.de, stable@vger.kernel.org, dave@stgolabs.net, Kiszka, Jan, bigeasy@linutronix.de, Ivanov, Petr On Tue, 2024-02-20 at 15:32 +0100, Greg KH wrote: > On Tue, Feb 20, 2024 at 01:34:03PM +0100, Felix Moessbauer wrote: > > From: Davidlohr Bueso <dave@stgolabs.net> > > > > commit 0c52310f260014d95c1310364379772cb74cf82d upstream. > > > > While in theory the timer can be triggered before expires + delta, > > for the > > cases of RT tasks they really have no business giving any lenience > > for > > extra slack time, so override any passed value by the user and > > always use > > zero for schedule_hrtimeout_range() calls. Furthermore, this is > > similar to > > what the nanosleep(2) family already does with current- > > >timer_slack_ns. > > > > Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > > Link: > > https://lore.kernel.org/r/20230123173206.6764-3-dave@stgolabs.net > > You can't forward on a patch without signing off on it as well :( Ok, thanks for the info. I'll add the signoff and send a v3. > > And this is already in the 6.1.53 release, why apply it again? I can't find it there and also the change is not included in linux- 6.1.y or 6.1.53. There is another commit referencing this patch (linux- 6.1.y, fd4d61f85e7625cb21a7eff4efa1de46503ed2c3), but the "hrtimer: Ignore slack time ..." patch did not get backported so far. I also checked the source of v6.1.y and could not find the related change. Which commit exactly are you referring to? Felix > > confused, > > greg k-h -- Siemens AG, Technology Linux Expert Center ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2][5.10, 5.15, 6.1][1/1] hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() 2024-02-20 14:49 ` MOESSBAUER, Felix @ 2024-02-20 14:58 ` gregkh 0 siblings, 0 replies; 5+ messages in thread From: gregkh @ 2024-02-20 14:58 UTC (permalink / raw) To: MOESSBAUER, Felix Cc: tglx@linutronix.de, stable@vger.kernel.org, dave@stgolabs.net, Kiszka, Jan, bigeasy@linutronix.de, Ivanov, Petr On Tue, Feb 20, 2024 at 02:49:00PM +0000, MOESSBAUER, Felix wrote: > On Tue, 2024-02-20 at 15:32 +0100, Greg KH wrote: > > On Tue, Feb 20, 2024 at 01:34:03PM +0100, Felix Moessbauer wrote: > > > From: Davidlohr Bueso <dave@stgolabs.net> > > > > > > commit 0c52310f260014d95c1310364379772cb74cf82d upstream. > > > > > > While in theory the timer can be triggered before expires + delta, > > > for the > > > cases of RT tasks they really have no business giving any lenience > > > for > > > extra slack time, so override any passed value by the user and > > > always use > > > zero for schedule_hrtimeout_range() calls. Furthermore, this is > > > similar to > > > what the nanosleep(2) family already does with current- > > > >timer_slack_ns. > > > > > > Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> > > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > > > Link: > > > https://lore.kernel.org/r/20230123173206.6764-3-dave@stgolabs.net > > > > You can't forward on a patch without signing off on it as well :( > > Ok, thanks for the info. I'll add the signoff and send a v3. > > > > > And this is already in the 6.1.53 release, why apply it again? > > I can't find it there and also the change is not included in linux- > 6.1.y or 6.1.53. There is another commit referencing this patch (linux- > 6.1.y, fd4d61f85e7625cb21a7eff4efa1de46503ed2c3), but the "hrtimer: > Ignore slack time ..." patch did not get backported so far. > I also checked the source of v6.1.y and could not find the related > change. Which commit exactly are you referring to? Ah, yes, that's my fault, my scripts picked up the full sha being referenced there as normally that's not how anyone does it in a changelog. So it will be needed for 6.1.y, thanks! greg k-h ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-20 14:58 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-02-20 12:34 [PATCH v2][5.10, 5.15, 6.1][0/1] hrtimer: Ignore slack time for RT tasks Felix Moessbauer 2024-02-20 12:34 ` [PATCH v2][5.10, 5.15, 6.1][1/1] hrtimer: Ignore slack time for RT tasks in schedule_hrtimeout_range() Felix Moessbauer 2024-02-20 14:32 ` Greg KH 2024-02-20 14:49 ` MOESSBAUER, Felix 2024-02-20 14:58 ` gregkh
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox