sched_ext: Simplify scx_can_stop_tick() invocation in sched_can_stop_tick()
authorTejun Heo <tj@kernel.org>
Tue, 6 Aug 2024 19:40:10 +0000 (09:40 -1000)
committerTejun Heo <tj@kernel.org>
Tue, 6 Aug 2024 19:40:10 +0000 (09:40 -1000)
commit11cc374f4643b1be16deab571e034409c6ee7e66
tree58cbe25ae36ba42e8b1dfba70781a0dc9bea40b9
parent0df340ceae2e51ccc6a8a19f4182f389223fbfdf
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>
kernel/sched/core.c