Skip to content

Commit 11cc374

Browse files
committed
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@kernel.org> Suggested-by: Peter Zijlstra <peterz@infradead.org> Acked-by: David Vernet <void@manifault.com>
1 parent 0df340c commit 11cc374

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/sched/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,10 +1286,10 @@ bool sched_can_stop_tick(struct rq *rq)
12861286
* left. For CFS, if there's more than one we need the tick for
12871287
* involuntary preemption. For SCX, ask.
12881288
*/
1289-
if (!scx_switched_all() && rq->nr_running > 1)
1289+
if (scx_enabled() && !scx_can_stop_tick(rq))
12901290
return false;
12911291

1292-
if (scx_enabled() && !scx_can_stop_tick(rq))
1292+
if (rq->cfs.nr_running > 1)
12931293
return false;
12941294

12951295
/*

0 commit comments

Comments
 (0)