From: sashiko-bot@kernel.org
To: "Tejun Heo" <tj@kernel.org>, sched-ext@lists.linux.dev
Subject: Re: [PATCH 06/14] sched_ext: Fix a cpu idling with a runnable rescuee
Date: Thu, 22 Oct 2026 21:56:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-182079@kernel.org> (raw)
In-Reply-To: <20261022213836.2259069-7-tj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] sched_ext: premature rescue end in dispatch_one() via keep-last check
--
commit e79ddf5c81c9e04dfc120cdedd71ae201dfeefb0
Author: Tejun Heo <tj@kernel.org>
sched_ext: Fix a cpu idling with a runnable rescuee
This commit updates dispatch_one() to call scx_rescue_keep() when no other
task is runnable so that a rescuee with a zeroed slice continues running on
its unserved rescue remainder instead of letting the CPU go idle.
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index e9224351e9dff..e587743b6136f 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -3389,6 +3389,26 @@ static enum scx_dsp_verdict dispatch_one(struct rq *rq, struct task_struct *prev
> verdict = SCX_DSP_PREV;
> goto has_tasks;
> }
> +
> + /*
> + * The scheduler preempts a rescuee like any other task by
> + * zeroing its slice. The grant survives the preemption. The
> + * rescuee gets the unserved remainder back and runs again
> + * behind whatever the scheduler wanted to run first.
> + *
> + * Two sites restore the remainder. When another task won the
> + * pick, put_prev_task_scx() restores it and queues the rescuee
> + * at the tail of the local DSQ.
> + *
> + * When nothing else is runnable, the cpu must not go idle with
> + * the rescuee queued. The keep above declined @prev, and a
> + * reinsert from put_prev_task_scx() would come after the pick
> + * settled on idle. Keep @prev running on the remainder here.
> + */
> + if (unlikely(prev == scx_rescuee(rq)) && scx_rescue_keep(rq, prev)) {
> + verdict = SCX_DSP_PREV;
> + goto has_tasks;
> + }
[Severity: Medium]
Should the scx_rescue_keep() check in kernel/sched/ext/ext.c:dispatch_one()
run before the SCX_EV_DISPATCH_KEEP_LAST check above it?
Right before this addition, dispatch_one() checks whether prev can stay on
the CPU:
if (prev->scx.flags & SCX_TASK_QUEUED) {
struct scx_sched *prev_sch = scx_task_sched(prev);
if ((!(prev_sch->ops.flags & SCX_OPS_ENQ_LAST) ||
scx_bypassing(prev_sch, cpu)) && scx_task_can_stay_on_cpu(rq, prev)) {
__scx_add_event(prev_sch, SCX_EV_DISPATCH_KEEP_LAST, 1);
verdict = SCX_DSP_PREV;
goto has_tasks;
}
In kernel/sched/ext/sub.h:scx_task_can_stay_on_cpu(), this condition returns
true for an active rescuee if the task is in a migrate_disable() section, or
if prev_sch holds SCX_CAP_BASE on the CPU (for instance, when the task was
diverted to rescue because an enqueue required SCX_CAP_ENQ or SCX_CAP_PREEMPT,
or if SCX_CAP_BASE was granted after the rescue started):
if (unlikely(is_migration_disabled(p)))
return true;
/* check caps against the sched running a bypassed task */
return likely(!scx_missing_caps(scx_exec_sched(scx_task_sched(p), cpu), cpu,
SCX_CAP_BASE));
When !(prev_sch->ops.flags & SCX_OPS_ENQ_LAST) and scx_task_can_stay_on_cpu()
is true, a rescuee whose slice was zeroed before serving its full rescue
quantum will take the SCX_EV_DISPATCH_KEEP_LAST branch and return
SCX_DSP_PREV with prev->scx.slice == 0 instead of calling scx_rescue_keep().
Then kernel/sched/ext/ext.c:do_pick_task_scx() sees !p->scx.slice:
if (verdict == SCX_DSP_PREV) {
p = prev;
if (!p->scx.slice) {
/* the slice is consumed, protection ends */
scx_task_slice_ended(rq, p);
refill_task_slice_dfl(scx_task_sched(p), p);
}
}
Wouldn't that call scx_task_slice_ended() -> scx_rescue_end() to terminate
the rescue prematurely and refill p->scx.slice with an unmetered default
slice instead of restoring the unserved rescue remainder?
> }
> rq->scx.flags &= ~SCX_RQ_IN_DISPATCH;
> return SCX_DSP_NONE;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261022213836.2259069-1-tj@kernel.org?part=6
next prev parent reply other threads:[~2026-10-22 21:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 21:38 [PATCHSET sched_ext/for-7.4] sched_ext: Fix bypassed sub-scheduler tasks stalling when the host lacks caps Tejun Heo
2026-10-22 21:38 ` [PATCH 01/14] sched_ext: Pack scx_ent_flags' multi-bit fields at the top Tejun Heo
2026-10-22 21:38 ` [PATCH 02/14] sched_ext: Clear holding_cpu where the claim is confirmed Tejun Heo
2026-10-22 21:38 ` [PATCH 03/14] sched_ext: Fix bypassed tasks looping on a host without SCX_CAP_ENQ Tejun Heo
2026-10-22 22:04 ` sashiko-bot
2026-10-23 0:03 ` Tejun Heo
2026-10-22 21:38 ` [PATCH 04/14] sched_ext: Move refill_task_slice_dfl() below apply_slice_vtime() Tejun Heo
2026-10-22 21:38 ` [PATCH 05/14] sched_ext: Restore a rescuee's slice after ops.stopping() Tejun Heo
2026-10-22 21:38 ` [PATCH 06/14] sched_ext: Fix a cpu idling with a runnable rescuee Tejun Heo
2026-10-22 21:56 ` sashiko-bot [this message]
2026-10-23 0:03 ` Tejun Heo
2026-10-22 21:38 ` [PATCH 07/14] sched_ext: Mark the rescue grant as a kernel slice with SCX_TASK_KERNEL_SLICE Tejun Heo
2026-10-22 21:38 ` [PATCH 08/14] sched_ext: Refuse extending a kernel slice Tejun Heo
2026-10-22 21:38 ` [PATCH 09/14] sched_ext: Fix a cpu idling after put_prev_task_scx() queues its task on the local DSQ Tejun Heo
2026-10-22 21:38 ` [PATCH 10/14] sched_ext: Fix bypassed tasks stalling when the host lacks SCX_CAP_BASE Tejun Heo
2026-10-22 22:09 ` sashiko-bot
2026-10-23 0:03 ` Tejun Heo
2026-10-22 21:38 ` [PATCH 11/14] sched_ext: Fix the bypass load balancer stranding tasks on cpus where " Tejun Heo
2026-10-22 21:38 ` [PATCH 12/14] sched_ext: Factor out bypass_lb_move() and insert with the donor DSQ unlocked Tejun Heo
2026-10-22 21:38 ` [PATCH 13/14] sched_ext: Let the bypass load balancer move tasks homed on other cpus Tejun Heo
2026-10-22 21:38 ` [PATCH 14/14] sched_ext: Fix queued bypassed tasks stalling when the host loses SCX_CAP_BASE Tejun Heo
2026-10-22 22:04 ` sashiko-bot
2026-10-23 0:03 ` Tejun Heo
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-182079@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