sched_ext: Call ops.update_idle() after updating builtin idle bits
authorTejun Heo <tj@kernel.org>
Wed, 21 May 2025 22:23:06 +0000 (12:23 -1000)
committerTejun Heo <tj@kernel.org>
Thu, 22 May 2025 19:25:15 +0000 (09:25 -1000)
commit273cc949655c70001778eb0b9e7db993df845912
treeae3f254ba1c83e9be7f0da01ba92f774a06dc07d
parentaa3a7b6261d8530da3d06c61d21b1acda54abf52
sched_ext: Call ops.update_idle() after updating builtin idle bits

BPF schedulers that use both builtin CPU idle mechanism and
ops.update_idle() may want to use the latter to create interlocking between
ops.enqueue() and CPU idle transitions so that either ops.enqueue() sees the
idle bit or ops.update_idle() sees the task queued somewhere. This can
prevent race conditions where CPUs go idle while tasks are waiting in DSQs.

For such interlocking to work, ops.update_idle() must be called after
builtin CPU masks are updated. Relocate the invocation. Currently, there are
no ordering requirements on transitions from idle and this relocation isn't
expected to make meaningful differences in that direction.

This also makes the ops.update_idle() behavior semantically consistent:
any action performed in this callback should be able to override the
builtin idle state, not the other way around.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-and-tested-by: Andrea Righi <arighi@nvidia.com>
Acked-by: Changwoo Min <changwoo@igalia.com>
kernel/sched/ext_idle.c