Sched_ext development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tejun Heo" <tj@kernel.org>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH 1/3] sched_ext: Add ops.sub_cid_sched_updated() to report the sched running on a cid
Date: Mon, 05 Oct 2026 18:10:12 +0000	[thread overview]
Message-ID: <20261005181013.43E6B1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261005175520.2756986-2-tj@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] sched_ext: skipped NONE notification for the last active scheduler
--

commit 24e8930bf2fb59df3460d85d232da97c8cc5102f
Author: Tejun Heo <tj@kernel.org>

sched_ext: Add ops.sub_cid_sched_updated() to report the sched running on a cid

This commit adds ops.sub_cid_sched_updated() to report changes in the
scheduler running on a specific cgroup ID. It maintains the notification
state using a static key that is disabled when the last interested scheduler
goes away.

> diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
> index 6b964743cab9b..59fc506af817e 100644
> --- a/kernel/sched/ext/sub.c
> +++ b/kernel/sched/ext/sub.c

[ ... ]

> @@ -92,6 +99,161 @@ struct scx_sched *scx_next_descendant_pre(struct scx_sched *pos, struct scx_sche

[ ... ]

> +void scx_cid_sched_update(struct rq *rq, struct scx_sched *sch)
> +{
> +	struct scx_sched *prev = rq->scx.sched;
> +	s32 level, common = -1;
> +
> +	lockdep_assert_rq_held(rq);
> +
> +	if (!static_branch_unlikely(&__scx_ops_cid_sched_updated_enabled) || prev == sch)
> +		return;

[ ... ]

> +void scx_ops_cid_sched_updated_disable(struct scx_sched *sch)
> +{
> +	bool last;
> +	s32 cpu;
> +
> +	lockdep_assert_held(&scx_enable_mutex);
> +
> +	last = SCX_HAS_OP(sch, sub_cid_sched_updated) && !--scx_nr_ops_cid_sched_updated;
> +	if (last)
> +		static_branch_disable(&__scx_ops_cid_sched_updated_enabled);
> +
> +	/*
> +	 * Re-homing restarts a running task's session under its new sched. A
> +	 * task that blocked while its cpu's dispatch had the rq lock dropped is
> +	 * put and set next again without a restart, so rq->scx.sched keeps @sch
> +	 * until the pick completes:
> +	 *
> +	 *   cpu 0, __schedule()                 cpu 1, scx_sub_disable(@sch)
> +	 *   T of @sch blocks, stops running
> +	 *   dispatch drops the rq lock
> +	 *                                       re-home T, nothing to restart
> +	 *                                       this sweep
> +	 *   pick N, N's session opens
> +	 *
> +	 * Closing the session here reports NONE to @sch and its ancestors now
> +	 * and lets the pick report N's sched from NONE instead of from @sch.
> +	 */
> +	for_each_possible_cpu(cpu) {
> +		struct rq *rq = cpu_rq(cpu);
> +
> +		guard(rq_lock_irqsave)(rq);
> +		if (rq->scx.sched == sch)
> +			scx_cid_sched_update(rq, NULL);

[Severity: Medium]
When disabling the last active scheduler, does this disable the static branch
too early?

In scx_ops_cid_sched_updated_disable(), if this is the last scheduler, the
static branch is turned off before the loop:

    last = SCX_HAS_OP(sch, sub_cid_sched_updated) && !--scx_nr_ops_cid_sched_updated;
    if (last)
        static_branch_disable(&__scx_ops_cid_sched_updated_enabled);

Then, the loop calls scx_cid_sched_update(rq, NULL). However,
scx_cid_sched_update() starts with an early return if the static branch is
disabled:

    if (!static_branch_unlikely(&__scx_ops_cid_sched_updated_enabled) || prev == sch)
        return;

Will this cause the final NONE state notification to be silently dropped for
the last BPF scheduler unloaded?

> +		if (last)
> +			rq->scx.sched = NULL;
> +	}
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261005175520.2756986-1-tj@kernel.org?part=1

  reply	other threads:[~2026-10-05 18:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 17:55 [PATCHSET sched_ext/for-7.4] sched_ext: Add ops.sub_cid_sched_updated() Tejun Heo
2026-10-05 17:55 ` [PATCH 1/3] sched_ext: Add ops.sub_cid_sched_updated() to report the sched running on a cid Tejun Heo
2026-10-05 18:10   ` sashiko-bot [this message]
2026-10-06 20:36     ` Tejun Heo
2026-10-05 17:55 ` [PATCH 2/3] sched_ext: scx_qmap: Size the cid range buffer for large machines Tejun Heo
2026-10-05 17:55 ` [PATCH 3/3] sched_ext: scx_qmap: Show actual cid use per participant Tejun Heo
2026-10-07  0:40 ` [PATCHSET sched_ext/for-7.4] sched_ext: Add ops.sub_cid_sched_updated() 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=20261005181013.43E6B1F000FF@smtp.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