linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -tip 0/2] kernel/hrtimer: Ignore slack time for RT tasks
@ 2023-01-23 17:32 Davidlohr Bueso
  2023-01-23 17:32 ` [PATCH 1/2] kernel/hrtimer: Rely on rt_task() for DL tasks too Davidlohr Bueso
  2023-01-23 17:32 ` [PATCH 2/2] kernel/hrtimer: Ignore slack time for RT tasks Davidlohr Bueso
  0 siblings, 2 replies; 4+ messages in thread
From: Davidlohr Bueso @ 2023-01-23 17:32 UTC (permalink / raw)
  To: tglx; +Cc: mingo, peterz, bigeasy, dave, linux-rt-users, linux-kernel

Hi,

Patch 2 simply ignores any user passed slack time in the case of RT/DL
tasks for schedule_hrtimeout_range, which is aligned to what nanosleep(2)
already does.

Thanks!

Davidlohr Bueso (2):
  kernel/hrtimer: Rely on rt_task() for DL tasks too
  kernel/hrtimer: Ignore slack time for RT tasks

 kernel/time/hrtimer.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

-- 
2.39.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] kernel/hrtimer: Rely on rt_task() for DL tasks too
  2023-01-23 17:32 [PATCH -tip 0/2] kernel/hrtimer: Ignore slack time for RT tasks Davidlohr Bueso
@ 2023-01-23 17:32 ` Davidlohr Bueso
  2023-01-31 10:24   ` Thomas Gleixner
  2023-01-23 17:32 ` [PATCH 2/2] kernel/hrtimer: Ignore slack time for RT tasks Davidlohr Bueso
  1 sibling, 1 reply; 4+ messages in thread
From: Davidlohr Bueso @ 2023-01-23 17:32 UTC (permalink / raw)
  To: tglx; +Cc: mingo, peterz, bigeasy, dave, linux-rt-users, linux-kernel

Having dl_task() is redundant, trivially simplify.

Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 kernel/time/hrtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 3ae661ab6260..8336c2618ec1 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -2089,7 +2089,7 @@ long hrtimer_nanosleep(ktime_t rqtp, const enum hrtimer_mode mode,
 	u64 slack;
 
 	slack = current->timer_slack_ns;
-	if (dl_task(current) || rt_task(current))
+	if (rt_task(current))
 		slack = 0;
 
 	hrtimer_init_sleeper_on_stack(&t, clockid, mode);
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] kernel/hrtimer: Ignore slack time for RT tasks
  2023-01-23 17:32 [PATCH -tip 0/2] kernel/hrtimer: Ignore slack time for RT tasks Davidlohr Bueso
  2023-01-23 17:32 ` [PATCH 1/2] kernel/hrtimer: Rely on rt_task() for DL tasks too Davidlohr Bueso
@ 2023-01-23 17:32 ` Davidlohr Bueso
  1 sibling, 0 replies; 4+ messages in thread
From: Davidlohr Bueso @ 2023-01-23 17:32 UTC (permalink / raw)
  To: tglx; +Cc: mingo, peterz, bigeasy, dave, linux-rt-users, linux-kernel

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>
---
 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 8336c2618ec1..78f2e07d3e7d 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -2270,7 +2270,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
  */
@@ -2297,6 +2297,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);
@@ -2316,7 +2323,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
@@ -2324,7 +2331,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.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] kernel/hrtimer: Rely on rt_task() for DL tasks too
  2023-01-23 17:32 ` [PATCH 1/2] kernel/hrtimer: Rely on rt_task() for DL tasks too Davidlohr Bueso
@ 2023-01-31 10:24   ` Thomas Gleixner
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2023-01-31 10:24 UTC (permalink / raw)
  To: Davidlohr Bueso
  Cc: mingo, peterz, bigeasy, dave, linux-rt-users, linux-kernel

On Mon, Jan 23 2023 at 09:32, Davidlohr Bueso wrote:

'kernel/hrtimer:' is not the correct prefix. Hint:

 git log --oneline path/to/file

I fixed that up for you this time....

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-31 10:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-23 17:32 [PATCH -tip 0/2] kernel/hrtimer: Ignore slack time for RT tasks Davidlohr Bueso
2023-01-23 17:32 ` [PATCH 1/2] kernel/hrtimer: Rely on rt_task() for DL tasks too Davidlohr Bueso
2023-01-31 10:24   ` Thomas Gleixner
2023-01-23 17:32 ` [PATCH 2/2] kernel/hrtimer: Ignore slack time for RT tasks Davidlohr Bueso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).