Skip to content

sched_ext: Fix entry-path contract breaks in core.c

Tao Cui bpf lkml sched-ext 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2sched/core: Pass ENQUEUE_RQ_SELECTED on initial enqueuekernel/sched/core.c+4 -12 replies
2/2sched_ext: Block a retained donor before PI deboost routes it back to sched_extkernel/sched/core.c kernel/sched/ext/ext.h+14 -07 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchTejun Heo
1/2A-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] sched_ext: Fix entry-path contract breaks in core.c

From: Tao Cui <[email protected]>

Hello,

wake_up_new_task() consults select_task_rq() but activates the new task without ENQUEUE_RQ_SELECTED, so on the fork path ops.enqueue() never sees SCX_ENQ_CPU_SELECTED and SCX_EV_SELECT_CPU_FALLBACK never counts a fork-path fallback; pass the flag on the initial enqueue to match the wakeup path. rt_mutex_setprio() is the only entry path into sched_ext that does not call sched_proxy_block_task(): an ext task PI-boosted by an rt waiter and blocked on a second kernel mutex is routed back to ext on deboost carrying the queued+blocked state that scx_prepare_setscheduler() promises never happens; block a retained donor before the deboost routes it back.

0001 passes the flag on the initial enqueue to match the wakeup path, and 0002 blocks a retained donor before the deboost routes it back to ext.

Verified in qemu on tj/sched_ext for-next (5b740a72b55c), same kernel and config with and without each patch, comparing stock and patched binaries; the touched core.c regions are byte-identical on this base, so the runs carry over: with a probe forcing select_cpu() fallbacks, 40k forks produce 0 fallback events on the baseline kernel while the wakeup side counts normally, and fork and wakeup paths both count 1:1 with patch 1; and a driver-model trigger hands the scheduler ~39966 queued+blocked donors across 40000 PI cycles on the baseline kernel with 0 with patch 2, PI chain traffic unchanged.

Based on sched_ext/for-next (5b740a72b55c).

Tao Cui (2):
sched/core: Pass ENQUEUE_RQ_SELECTED on initial enqueue
sched_ext: Block a retained donor before PI deboost routes it back to
sched_ext

 kernel/sched/core.c    | 17 ++++++++++++++++-
 kernel/sched/ext/ext.h |  2 ++
 2 files changed, 18 insertions(+), 1 deletion(-)
Signature · 1 line
2.53.0