mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] tools/sched_ext: Fix three example scheduler bugs
@ 2026-09-24 14:36 Wanwu Li
  2026-09-24 14:36 ` [PATCH 1/3] tools/sched_ext: Increment nr_queued when a task is queued to user space Wanwu Li
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Wanwu Li @ 2026-09-24 14:36 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Andrea Righi, Changwoo Min
  Cc: sched-ext, linux-kernel, Wanwu Li

Patch 1 fixes scx_userland, where the BPF component never increments
nr_queued although both its declaration comment and the NOTE in
userland_update_idle() say it does.  As a result the "wake the
user-space scheduler when a CPU goes idle" decision silently degrades
to nr_scheduled alone and tasks sitting in the enqueued map are
invisible to it.

Patches 2 and 3 fix two related queue-lifetime bugs in scx_pair, which
has no .dequeue and no .cgroup_move callback and therefore leaves stale
pids in the per-cgroup FIFOs:

 - pair_cgroup_exit() releases a queue slot without draining it.  The
   next cgroup inheriting the slot starts with a stale non-zero
   cgrp_q_len, so its first enqueue never sees the 0 -> 1 transition
   and its cgid is never queued on top_q: the cgroup starves for the
   lifetime of the scheduler.

 - try_dispatch() trusts a pid popped from a cgroup's FIFO.  If the
   task migrated to another cgroup between enqueue and dispatch, it is
   dispatched under the old cgroup's context, violating the core
   "paired CPUs only run tasks from the same cgroup" invariant.

Wanwu Li (3):
  tools/sched_ext: Increment nr_queued when a task is queued to user
    space
  tools/sched_ext: scx_pair: Drain task queue on cgroup exit
  tools/sched_ext: scx_pair: Verify task cgroup before dispatch

 tools/sched_ext/scx_pair.bpf.c     | 47 ++++++++++++++++++++++++++++++++++++++
 tools/sched_ext/scx_userland.bpf.c |  1 +
 2 files changed, 48 insertions(+)

-- 
2.25.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-24 16:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 14:36 [PATCH 0/3] tools/sched_ext: Fix three example scheduler bugs Wanwu Li
2026-09-24 14:36 ` [PATCH 1/3] tools/sched_ext: Increment nr_queued when a task is queued to user space Wanwu Li
2026-09-24 14:36 ` [PATCH 2/3] tools/sched_ext: scx_pair: Drain task queue on cgroup exit Wanwu Li
2026-09-24 14:36 ` [PATCH 3/3] tools/sched_ext: scx_pair: Verify task cgroup before dispatch Wanwu Li
2026-09-24 16:17 ` [PATCH 0/3] tools/sched_ext: Fix three example scheduler bugs Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®