Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+2 -2
+2 -2
kernel/sched/core.c
··· 1286 1286 * left. For CFS, if there's more than one we need the tick for 1287 1287 * involuntary preemption. For SCX, ask. 1288 1288 */ 1289 - if (!scx_switched_all() && rq->nr_running > 1) 1289 + if (scx_enabled() && !scx_can_stop_tick(rq)) 1290 1290 return false; 1291 1291 1292 - if (scx_enabled() && !scx_can_stop_tick(rq)) 1292 + if (rq->cfs.nr_running > 1) 1293 1293 return false; 1294 1294 1295 1295 /*