From: Tao Cui <cui.tao@linux.dev>
To: Andrea Righi <arighi@nvidia.com>,
Peter Zijlstra <peterz@infradead.org>, Tejun Heo <tj@kernel.org>
Cc: cui.tao@linux.dev, Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
John Stultz <jstultz@google.com>,
David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>, Tao Cui <cuitao@kylinos.cn>,
sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] selftests/sched_ext: Check that blocked donors are never enqueued unadmitted
Date: Wed, 2 Dec 2026 11:08:48 +0800 [thread overview]
Message-ID: <4b0a4f64-2bf1-4ed8-9bf3-55f7d6da69c5@linux.dev> (raw)
In-Reply-To: <20261126111649.208476-5-arighi@nvidia.com>
Hello, Andrea,
在 2026/11/26 19:14, Andrea Righi 写道:
> enq_blocked attaches the BPF scheduler while the fair class retains a
> mutex-blocked donor, so the root enable moves the donor into sched_ext
> through switching_to_scx(), the same path taken by every other class
> transition into sched_ext, such as PI deboost or sched_setscheduler().
>
> On top of the donor state checks, verify that ops.enqueue() never sees a
> retained donor without SCX_ENQ_BLOCKED during the whole run, including
> the scheduler attachment. A full wakeup enqueue happens before
> is_blocked is cleared, so SCX_ENQ_WAKEUP enqueues are not counted.
>
One thing I noticed while testing patches 1-3: on the baseline kernel,
ops.enqueue() is called for the PI-deboosted donor only about a third of
the time. The donor appears to keep SCX_TASK_QUEUED across the RT
excursion, so enqueue_task_scx() takes the SCX_TASK_QUEUED early-out. In
the minority of runs where ops.enqueue() is reached, is_blocked has
already been cleared.
So this counter would have read 0 even on the baseline kernel and
wouldn't detect the behavior this series fixes. It doesn't affect the
conclusions from the test, the donor state checks still verify the
entry path, I'm just noting it here in case someone later relies on
that counter to catch a deboost regression.
Thanks,
Tao
> Signed-off-by: Andrea Righi <arighi@nvidia.com>
> ---
> tools/testing/selftests/sched_ext/enq_blocked.bpf.c | 9 +++++++++
> tools/testing/selftests/sched_ext/enq_blocked.c | 11 +++++++++--
> 2 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/sched_ext/enq_blocked.bpf.c b/tools/testing/selftests/sched_ext/enq_blocked.bpf.c
> index 212690bf4e07b..72d562f16b694 100644
> --- a/tools/testing/selftests/sched_ext/enq_blocked.bpf.c
> +++ b/tools/testing/selftests/sched_ext/enq_blocked.bpf.c
> @@ -20,6 +20,7 @@ u64 nr_blocked_enqueues_donor_cpu;
> u64 nr_blocked_enqueues_owner_cpu;
> u64 nr_blocked_enqueues_other_cpu;
> u64 nr_blocked_wakeups;
> +u64 nr_unadmitted_enqueues;
> static u64 vtime_now;
>
> UEI_DEFINE(uei);
> @@ -34,6 +35,14 @@ void BPF_STRUCT_OPS(enq_blocked_enqueue, struct task_struct *p, u64 enq_flags)
> {
> u64 vtime = p->scx.dsq_vtime;
>
> + /*
> + * A retained proxy donor must only be enqueued with SCX_ENQ_BLOCKED. A
> + * full wakeup enqueue happens before is_blocked is cleared.
> + */
> + if (p->pid == donor_pid && p->is_blocked &&
> + !(enq_flags & (SCX_ENQ_BLOCKED | SCX_ENQ_WAKEUP)))
> + __sync_fetch_and_add(&nr_unadmitted_enqueues, 1);
> +
> if (enq_flags & SCX_ENQ_BLOCKED) {
> int cpu = scx_bpf_task_cpu(p);
>
> diff --git a/tools/testing/selftests/sched_ext/enq_blocked.c b/tools/testing/selftests/sched_ext/enq_blocked.c
> index 54ee5633c5720..ec6ffb9625fb8 100644
> --- a/tools/testing/selftests/sched_ext/enq_blocked.c
> +++ b/tools/testing/selftests/sched_ext/enq_blocked.c
> @@ -497,7 +497,7 @@ static enum scx_test_status run_one(bool enq_blocked, bool cross_cpu,
> size_t i, nr_contenders, nr_contenders_started = 0;
> size_t nr_contenders_joined = 0;
> u64 nr_blocked, nr_blocked_donor_cpu, nr_blocked_owner_cpu;
> - u64 nr_blocked_other_cpu, nr_blocked_wakeups;
> + u64 nr_blocked_other_cpu, nr_blocked_wakeups, nr_unadmitted;
> struct enq_blocked_stats stats;
>
> err = select_test_cpus(cross_cpu, &allowed_cpus, &thread_ctx.donor_cpu,
> @@ -815,6 +815,7 @@ static enum scx_test_status run_one(bool enq_blocked, bool cross_cpu,
> nr_blocked_owner_cpu = skel->bss->nr_blocked_enqueues_owner_cpu;
> nr_blocked_other_cpu = skel->bss->nr_blocked_enqueues_other_cpu;
> nr_blocked_wakeups = skel->bss->nr_blocked_wakeups;
> + nr_unadmitted = skel->bss->nr_unadmitted_enqueues;
> result->nr_blocked_enqueues = nr_blocked;
> result->nr_blocked_enqueues_donor_cpu = nr_blocked_donor_cpu;
> result->nr_blocked_enqueues_owner_cpu = nr_blocked_owner_cpu;
> @@ -830,8 +831,14 @@ static enum scx_test_status run_one(bool enq_blocked, bool cross_cpu,
> (unsigned long long)nr_blocked_other_cpu);
> printf(" nr_blocked_wakeups=%llu\n",
> (unsigned long long)nr_blocked_wakeups);
> + printf(" nr_unadmitted_enqueues=%llu\n",
> + (unsigned long long)nr_unadmitted);
> if (status == SCX_TEST_PASS) {
> - if (enq_blocked && proxy_enabled && !nr_blocked) {
> + if (nr_unadmitted) {
> + SCX_ERR("ops.enqueue() received %llu blocked donors without SCX_ENQ_BLOCKED",
> + (unsigned long long)nr_unadmitted);
> + status = SCX_TEST_FAIL;
> + } else if (enq_blocked && proxy_enabled && !nr_blocked) {
> SCX_ERR("ops.enqueue() did not receive the blocked donor");
> status = SCX_TEST_FAIL;
> } else if ((!enq_blocked || !proxy_enabled) && nr_blocked) {
prev parent reply other threads:[~2026-12-02 3:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 11:13 [PATCHSET sched_ext/for-7.5] sched/proxy: Handle retained donors on scheduling class transitions Andrea Righi
2026-11-26 11:13 ` [PATCH 1/4] sched: Let switching_to() decide whether to keep a retained proxy donor Andrea Righi
2026-11-26 16:01 ` Peter Zijlstra
2026-11-28 16:42 ` Andrea Righi
2026-12-02 3:06 ` Tao Cui
2026-11-26 11:13 ` [PATCH 2/4] sched_ext: Make SCX_OPS_ENQ_BLOCKED a hierarchy-wide setting Andrea Righi
2026-11-27 20:29 ` Tejun Heo
2026-11-28 16:39 ` Andrea Righi
2026-11-28 16:53 ` Andrea Righi
2026-11-29 7:46 ` Tejun Heo
2026-11-29 8:25 ` Andrea Righi
2026-11-26 11:13 ` [PATCH 3/4] sched: Remove sched_proxy_block_task() Andrea Righi
2026-11-26 11:14 ` [PATCH 4/4] selftests/sched_ext: Check that blocked donors are never enqueued unadmitted Andrea Righi
2026-12-02 3:08 ` Tao Cui [this message]
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=4b0a4f64-2bf1-4ed8-9bf3-55f7d6da69c5@linux.dev \
--to=cui.tao@linux.dev \
--cc=arighi@nvidia.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=cuitao@kylinos.cn \
--cc=dietmar.eggemann@arm.com \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--cc=vschneid@redhat.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