From: sashiko-bot@kernel.org
To: "Tejun Heo" <tj@kernel.org>, sched-ext@lists.linux.dev
Subject: Re: [PATCH v3 sched_ext/for-7.4-fixes] sched_ext: Fix stale pick when a wakeup resets the donor during dispatch
Date: Sat, 31 Oct 2026 02:19:12 +0000 [thread overview]
Message-ID: <sashiko-outbox-191703@kernel.org> (raw)
In-Reply-To: <20261031015414.219280-1-tj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] sched: stale rq->dl_server across RETRY_TASK in __pick_next_task()
--
commit e0269d8eaf30fac4dcf0d1178a69b8f7a54ecfe2
Author: Tejun Heo <tj@kernel.org>
sched_ext: Fix stale pick when a wakeup resets the donor during dispatch
This commit restarts the sched_ext pick when the proxy execution donor passed
as prev to dispatch_one() is reset to rq->curr while the rq lock is dropped,
and avoids passing a stale prev to ops.dispatch() or keeping it afterwards.
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index ffaab9fafca87..fe1be3d9444dd 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -3407,6 +3407,12 @@ static enum scx_dsp_verdict dispatch_one(struct rq *rq, struct task_struct *prev
> rq->scx.cpu_released = false;
> }
>
> + /* the ecaps sync may have dropped the rq lock */
> + if (scx_dsp_prev_stale(rq, prev)) {
> + verdict = SCX_DSP_RETRY;
> + goto out;
> + }
> +
> if (prev->sched_class == &ext_sched_class) {
> update_curr_scx(rq);
>
> @@ -3449,8 +3455,19 @@ static enum scx_dsp_verdict dispatch_one(struct rq *rq, struct task_struct *prev
> }
>
> verdict = scx_dispatch_sched(root_sch, rq, prev, false);
> - if (verdict != SCX_DSP_NONE)
> +
> + /* scx_dispatch_sched() may have dropped the rq lock */
> + if (scx_dsp_prev_stale(rq, prev))
> + verdict = SCX_DSP_RETRY;
> +
> + switch (verdict) {
> + case SCX_DSP_RETRY:
> + goto out;
[Severity: Medium]
As reported by Andrea Righi on v1 [1], can returning SCX_DSP_RETRY from
dispatch_one() leave a stale rq->dl_server pointer across a pick restart in
__pick_next_task()?
When __pick_next_task() calls pick_task_dl() -> __pick_task_dl() ->
ext_server_pick_task() -> do_pick_task_scx() -> dispatch_pick() ->
dispatch_one(), returning SCX_DSP_RETRY causes do_pick_task_scx() to return
RETRY_TASK even when force_scx is true:
kernel/sched/ext/ext.c:do_pick_task_scx() {
...
if (verdict == SCX_DSP_RETRY) {
p = RETRY_TASK;
goto out;
}
...
}
In __pick_task_dl(), server_pick_task() is only checked for NULL, so
RETRY_TASK causes rq->dl_server to be assigned before returning RETRY_TASK:
kernel/sched/deadline.c:__pick_task_dl() {
...
if (dl_server(dl_se)) {
p = dl_se->server_pick_task(dl_se, rf);
if (!p) {
dl_server_stop(dl_se);
goto again;
}
rq->dl_server = dl_se;
}
...
return p;
}
Unlike pick_task() under CONFIG_SCHED_CORE, __pick_next_task() clears
rq->dl_server before the restart label:
kernel/sched/core.c:__pick_next_task() {
rq->dl_server = NULL;
if (scx_enabled())
goto restart;
...
restart:
prev_balance(rq, rf);
for_each_active_class(class) {
p = class->pick_task(rq, rf);
if (unlikely(p == RETRY_TASK))
goto restart;
if (p) {
put_prev_set_next_task(rq, rq->donor, p);
return p;
}
}
}
If the restarted pass picks a non-server task (for example, if the woken
donor was the only sched_ext task on rq and migrated away so
ext_server_pick_task() returns NULL, or if a stopper or earlier-deadline DL
task is picked), put_prev_set_next_task() -> __put_prev_set_next_dl_server()
will attach the stale rq->dl_server (&rq->ext_server) to next->dl_server on a
non-server task.
Should __pick_next_task() clear rq->dl_server = NULL after the restart label
(or should __pick_task_dl() avoid setting rq->dl_server when server_pick_task
returns RETRY_TASK)?
[1] https://lore.kernel.org/r/auTNPtiaPyO9R5NG@gpd4
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261031015414.219280-1-tj@kernel.org?part=1
next prev parent reply other threads:[~2026-10-31 2:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 1:54 [PATCH v3 sched_ext/for-7.4-fixes] sched_ext: Fix stale pick when a wakeup resets the donor during dispatch Tejun Heo
2026-10-31 2:19 ` sashiko-bot [this message]
2026-10-31 7:58 ` Andrea Righi
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=sashiko-outbox-191703@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
/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