sched_ext: Choose prev_cpu if it is idle and cache affine

Consider that the previous CPU is cache affined to the waker's CPU and
is idle. Currently, scx's default select function only selects the
previous CPU in this case if WF_SYNC request is made to wakeup on the
waker's CPU.

This means, without WF_SYNC, the previous CPU being cache affined to the
waker and is idle is not considered. This seems extreme. WF_SYNC is not
normally passed to the wakeup path outside of some IPC drivers but it is
very possible that the task is cache hot on previous CPU and shares
cache with the waker CPU. Lets avoid too many migrations and select the
previous CPU in such cases.

This is consistent with fair scheduler as well. In
select_idle_sibling(), the previous CPU is selected if it is cache
affined with the target. This is done regardless of WF_SYNC and before
any scanning of fully idle cores is done.

One difference still exists though between SCX and CFS in this regard,
in CFS we first check if the target CPU is idle before checking if the
previous CPU is idle. However that seems a matter of choice.

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
1 file changed