]> www.infradead.org Git - users/willy/xarray.git/commit
sched_ext: Synchronize bypass state changes with rq lock
authorTejun Heo <tj@kernel.org>
Mon, 9 Sep 2024 23:29:42 +0000 (13:29 -1000)
committerTejun Heo <tj@kernel.org>
Tue, 10 Sep 2024 20:43:32 +0000 (10:43 -1000)
commit750a40d816de1567bd08f1017362f6e54e6549dc
treedba3a92472616410ec6098c54c64fa96e1ab24e7
parent2d285d561543d76b4a13263731b447e646c258f2
sched_ext: Synchronize bypass state changes with rq lock

While the BPF scheduler is being unloaded, the following warning messages
trigger sometimes:

 NOHZ tick-stop error: local softirq work is pending, handler #80!!!

This is caused by the CPU entering idle while there are pending softirqs.
The main culprit is the bypassing state assertion not being synchronized
with rq operations. As the BPF scheduler cannot be trusted in the disable
path, the first step is entering the bypass mode where the BPF scheduler is
ignored and scheduling becomes global FIFO.

This is implemented by turning scx_ops_bypassing() true. However, the
transition isn't synchronized against anything and it's possible for enqueue
and dispatch paths to have different ideas on whether bypass mode is on.

Make each rq track its own bypass state with SCX_RQ_BYPASSING which is
modified while rq is locked.

This removes most of the NOHZ tick-stop messages but not completely. I
believe the stragglers are from the sched core bug where pick_task_scx() can
be called without preceding balance_scx(). Once that bug is fixed, we should
verify that all occurrences of this error message are gone too.

v2: scx_enabled() test moved inside the for_each_possible_cpu() loop so that
    the per-cpu states are always synchronized with the global state.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: David Vernet <void@manifault.com>
kernel/sched/ext.c
kernel/sched/sched.h