[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240804024047.100355-2-tj@kernel.org>
Date: Sat, 3 Aug 2024 16:40:08 -1000
From: Tejun Heo <tj@...nel.org>
To: void@...ifault.com,
peterz@...radead.org
Cc: linux-kernel@...r.kernel.org,
kernel-team@...a.com,
mingo@...hat.com,
Tejun Heo <tj@...nel.org>
Subject: [PATCH 1/6] sched_ext: Simplify scx_can_stop_tick() invocation in sched_can_stop_tick()
The way sched_can_stop_tick() used scx_can_stop_tick() was rather confusing
and the behavior wasn't ideal when SCX is enabled in partial mode. Simplify
it so that:
- scx_can_stop_tick() can say no if scx_enabled().
- CFS tests rq->cfs.nr_running > 1 instead of rq->nr_running.
This is easier to follow and leads to the correct answer whether SCX is
disabled, enabled in partial mode or all tasks are switched to SCX.
Peter, note that this is a bit different from your suggestion where
sched_can_stop_tick() unconditionally returns scx_can_stop_tick() iff
scx_switched_all(). The problem is that in partial mode, tick can be stopped
when there is only one SCX task even if the BPF scheduler didn't ask and
isn't ready for it.
Signed-off-by: Tejun Heo <tj@...nel.org>
Suggested-by: Peter Zijlstra <peterz@...radead.org>
---
kernel/sched/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 22f86d5e9231..7994118eee53 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1267,10 +1267,10 @@ bool sched_can_stop_tick(struct rq *rq)
* left. For CFS, if there's more than one we need the tick for
* involuntary preemption. For SCX, ask.
*/
- if (!scx_switched_all() && rq->nr_running > 1)
+ if (scx_enabled() && !scx_can_stop_tick(rq))
return false;
- if (scx_enabled() && !scx_can_stop_tick(rq))
+ if (rq->cfs.nr_running > 1)
return false;
/*
--
2.46.0
Powered by blists - more mailing lists