]> www.infradead.org Git - users/hch/configfs.git/commit
sched_ext: Handle cases where pick_task_scx() is called without preceding balance_scx()
authorTejun Heo <tj@kernel.org>
Sat, 9 Nov 2024 20:43:55 +0000 (10:43 -1000)
committerTejun Heo <tj@kernel.org>
Sat, 9 Nov 2024 20:43:55 +0000 (10:43 -1000)
commita6250aa251eacaf3ebfcfe152a96a727fd483ecd
tree763a6d78a04ea2d66f8baa2406d7c704094f7f6f
parenta759bf0dfc4db3cb6556fc79c7c98da3a46b2b80
sched_ext: Handle cases where pick_task_scx() is called without preceding balance_scx()

sched_ext dispatches tasks from the BPF scheduler from balance_scx() and
thus every pick_task_scx() call must be preceded by balance_scx(). While
this usually holds, due to a bug, there are cases where the fair class's
balance() returns true indicating that it has tasks to run on the CPU and
thus terminating balance() calls but fails to actually find the next task to
run when pick_task() is called. In such cases, pick_task_scx() can be called
without preceding balance_scx().

Detect this condition using SCX_RQ_BAL_PENDING flags. If detected, keep
running the previous task if possible and avoid stalling from entering idle
without balancing.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/Ztj_h5c2LYsdXYbA@slm.duckdns.org
kernel/sched/core.c
kernel/sched/ext.c
kernel/sched/sched.h