From: sashiko-bot@kernel.org
To: "Tao Cui" <cui.tao@linux.dev>
Cc: sched-ext@lists.linux.dev, bpf@vger.kernel.org
Subject: Re: [PATCH 3/9] tools/sched_ext: scx_pair: Don't abort when the dispatching cgroup goes away
Date: Tue, 10 Nov 2026 12:59:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-207063@kernel.org> (raw)
In-Reply-To: <20261110125001.4167503-4-cui.tao@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched_ext: scx_pair: leaked active_mask bit in try_dispatch()
stalls pair
--
commit 0bc135e247824dc3899acf0f6cf608c43ee6328b
Author: Tao Cui <cuitao@kylinos.cn>
tools/sched_ext: scx_pair: Don't abort when the dispatching cgroup goes away
This commit changes try_dispatch() in scx_pair to mark the CPU pair as
draining and return instead of calling scx_bpf_error() when looking up the
current cgroup ID in cgrp_q_idx_hash fails.
> diff --git a/tools/sched_ext/scx_pair.bpf.c b/tools/sched_ext/scx_pair.bpf.c
> index 0d61b7b812db6..d38d3a078adee 100644
> --- a/tools/sched_ext/scx_pair.bpf.c
> +++ b/tools/sched_ext/scx_pair.bpf.c
> @@ -478,8 +478,16 @@ static int try_dispatch(s32 cpu)
> /* again, it'd be better to do all these with the lock held, oh well */
> vptr = bpf_map_lookup_elem(&cgrp_q_idx_hash, &cgid);
> if (!vptr) {
> - scx_bpf_error("failed to lookup q_idx for cgroup[%llu]", cgid);
> - return -ENOENT;
> + /*
> + * @cgid can disappear from under us: pair_cgroup_exit()
> + * drops the hash entry when the cgroup is going away.
> + * Mark the pair as drained and let the next dispatch
> + * expire it instead of taking the whole scheduler down.
> + */
> + bpf_spin_lock(&pairc->lock);
> + pairc->draining = true;
> + bpf_spin_unlock(&pairc->lock);
> + goto out_maybe_kick;
> }
[Severity: Medium]
Does this path need to clear in_pair_mask from pairc->active_mask and return
-EAGAIN, like the empty-cgroup path just below?
Before dropping pairc->lock to look up cgid in cgrp_q_idx_hash,
try_dispatch() sets pairc->active_mask |= in_pair_mask. Jumping to
out_maybe_kick returns 0 without dispatching a task, so pair_dispatch() stops
retrying and the current CPU goes idle with its bit still set in
pairc->active_mask. When the sibling CPU enters try_dispatch() and sees
pairc->draining set, it checks pairc->active_mask, assumes this idle CPU is
still running a task from the old cgroup, and bails out without switching to
the next cgroup in top_q, stalling the pair.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110125001.4167503-1-cui.tao@linux.dev?part=3
next prev parent reply other threads:[~2026-11-10 12:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 12:49 [PATCH 0/9] tools/sched_ext: robustness fixes from cold review Tao Cui
2026-11-10 12:49 ` [PATCH 1/9] tools/sched_ext: scx_flatcg: Reset the stats baseline on restart Tao Cui
2026-11-10 12:49 ` [PATCH 2/9] tools/sched_ext: scx_flatcg: Validate the stats interval Tao Cui
2026-11-10 12:49 ` [PATCH 3/9] tools/sched_ext: scx_pair: Don't abort when the dispatching cgroup goes away Tao Cui
2026-11-10 12:59 ` sashiko-bot [this message]
2026-11-10 12:49 ` [PATCH 4/9] tools/sched_ext: scx_pair: Don't attach after an interrupted initialization Tao Cui
2026-11-10 12:49 ` [PATCH 5/9] tools/sched_ext: scx_pair: Reset pair_id on restart Tao Cui
2026-11-10 12:49 ` [PATCH 6/9] tools/sched_ext: scx_qmap: Add the missing options to the usage synopsis Tao Cui
2026-11-10 12:49 ` [PATCH 7/9] tools/sched_ext: scx_qmap: Reset the hier stats baseline on restart Tao Cui
2026-11-10 12:50 ` [PATCH 8/9] tools/sched_ext: scx_userland: Check dispatch buffer slots before inserting Tao Cui
2026-11-11 21:05 ` bot+bpf-ci
2026-11-10 12:50 ` [PATCH 9/9] tools/sched_ext: scx_userland: Reject batch size 0 Tao Cui
2026-11-10 13:01 ` sashiko-bot
2026-11-10 19:17 ` [PATCH 0/9] tools/sched_ext: robustness fixes from cold review Tejun Heo
[not found] ` <CA+XhMqzQXn4r57b+CP-mryhat3rtg3bD2BaRLqjjqwEj1eJ-EA@mail.gmail.com>
2026-11-11 5:17 ` Tao Cui
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-207063@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cui.tao@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sched-ext@lists.linux.dev \
/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