From: zhidao su <soolaugust@gmail.com>
To: sched-ext@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, tj@kernel.org, void@manifault.com,
arighi@nvidia.com, changwoo@igalia.com, peterz@infradead.org,
mingo@redhat.com, zhidao su <suzhidao@xiaomi.com>
Subject: [PATCH 0/4] sched_ext: fix three unreliable selftests and compat kfunc signature
Date: Fri, 27 Mar 2026 04:42:34 +0800 [thread overview]
Message-ID: <20260326204238.3755737-1-suzhidao@xiaomi.com> (raw)
Three selftests added in c50dcf533149 ("selftests/sched_ext: Add tests
for SCX_ENQ_IMMED and scx_bpf_dsq_reenq()") have design flaws that
prevent them from reliably triggering the kernel behavior they were
written to verify. This series fixes all three, plus a related
compat.bpf.h signature bug.
- Patch 1: compat.bpf.h declares scx_bpf_dsq_reenq___compat with an
explicit aux__prog parameter, but scx_bpf_dsq_reenq() is a
KF_IMPLICIT_ARGS kfunc, so the BPF-side declaration must NOT include
the implicit parameter.
- Patch 2 (enq_immed): when the IMMED slow path fires, reenqueued tasks
were re-inserted into CPU 0's local DSQ, immediately re-triggering
the slow path and creating an infinite cycle that hits
SCX_REENQ_LOCAL_MAX_REPEAT (256). Fix: redirect reenqueued tasks to
SCX_DSQ_GLOBAL.
- Patch 3 (dsq_reenq): dispatch consumed USER_DSQ directly, racing with
the 5 ms BPF timer. By the time the timer fired, USER_DSQ was empty
and scx_bpf_dsq_reenq() found nothing to reenqueue. Fix: two-DSQ
design where USER_DSQ is never touched by dispatch.
- Patch 4 (consume_immed): workers were spread across all CPUs, so
USER_DSQ usually had only one task and dsq->nr never exceeded 1. Fix:
pin all workers to CPU 0 via CPU affinity so USER_DSQ always has
backlog; add dispatch loop to accumulate 2+ tasks and reliably trigger
the IMMED slow path.
All three tests verified with virtme-ng (PASSED: 30, FAILED: 0 across
the full sched_ext selftest suite).
zhidao su (4):
tools/sched_ext: compat.bpf.h: fix scx_bpf_dsq_reenq___compat
signature
selftests/sched_ext: enq_immed: fix IMMED reenqueue livelock
selftests/sched_ext: dsq_reenq: fix reliability with two-DSQ design
selftests/sched_ext: consume_immed: fix reliability with CPU affinity
tools/sched_ext/include/scx/compat.bpf.h | 4 +-
.../selftests/sched_ext/consume_immed.bpf.c | 19 ++++++--
.../selftests/sched_ext/consume_immed.c | 15 +++++--
.../selftests/sched_ext/dsq_reenq.bpf.c | 45 ++++++++++++++-----
.../selftests/sched_ext/enq_immed.bpf.c | 10 ++++-
5 files changed, 73 insertions(+), 20 deletions(-)
--
2.43.0
next reply other threads:[~2026-03-26 20:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 20:42 zhidao su [this message]
2026-03-26 20:42 ` [PATCH 1/4] tools/sched_ext: compat.bpf.h: fix scx_bpf_dsq_reenq___compat signature zhidao su
2026-03-27 0:42 ` Tejun Heo
2026-03-26 20:42 ` [PATCH 2/4] selftests/sched_ext: enq_immed: fix IMMED reenqueue livelock zhidao su
2026-03-26 20:42 ` [PATCH 3/4] selftests/sched_ext: dsq_reenq: fix reliability with two-DSQ design zhidao su
2026-03-26 20:42 ` [PATCH 4/4] selftests/sched_ext: consume_immed: fix reliability with CPU affinity zhidao su
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260326204238.3755737-1-suzhidao@xiaomi.com \
--to=soolaugust@gmail.com \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=sched-ext@lists.linux.dev \
--cc=suzhidao@xiaomi.com \
--cc=tj@kernel.org \
--cc=void@manifault.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®