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 6/6] sched_ext: Fix rq->core_pick corruption under core scheduling
Date: Fri, 07 Aug 2026 21:22:32 +0000	[thread overview]
Message-ID: <20260807212232.B43FF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807210221.232543-7-tj@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Under core scheduling, a pending kick-sync operation is silently ignored and lost when a sibling CPU performs the core-wide pick, breaking the wait guarantees of the scx_bpf_kick_cpu() kfunc.
--

--- Patch [6]: [PATCH 6/6] sched_ext: Fix rq->core_pick corruption under core scheduling ---
commit 80aba2ffb0bb3ad3c3cd2d54f2eb79683a1d623d
Author: Tejun Heo <tj@kernel.org>

sched_ext: Fix rq->core_pick corruption under core scheduling

This commit addresses an issue in sched_ext under core scheduling where
dispatching could drop the rq lock and corrupt the core-wide selection state.
It fixes this by restarting the selection when dispatch releases the lock,
ensuring picks are committed atomically.

Link: https://github.com/sched-ext/scx/issues/3715

> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index ebe40953acf01..c704588854879 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c

[ ... ]

> @@ -3241,6 +3242,70 @@ static enum scx_dsp_verdict dispatch_pick(struct rq *rq, struct rq_flags *rf,
>  	return verdict;
>  }
>  
> +#ifdef CONFIG_SCHED_CORE
> +/*
> + * Dispatch for a pick when core scheduling is enabled. The selection picks for
> + * all SMT siblings and the rq_i->core_pick state it builds must stay atomic
> + * throughout. If the dispatch released the rq lock, anything can have happened
> + * in between - return %SCX_DSP_RETRY to restart the selection against current
> + * state.
> + */
> +static enum scx_dsp_verdict dispatch_core_pick(struct rq *rq, struct rq_flags *rf,
> +					       struct task_struct *prev)
> +{
> +	enum scx_dsp_verdict verdict;
> +	u32 seq = rq->scx.lock_drop_seq;
> +
> +	/* another dispatch is in flight on @rq, let that handle it */
> +	if (rq->scx.flags & SCX_RQ_IN_BALANCE)
> +		return SCX_DSP_NONE;
> +
> +	rq_unpin_lock(rq, rf);
> +
> +	verdict = balance_one(rq, prev);
> +
> +	if (cpu_of(rq) == smp_processor_id()) {
> +		maybe_queue_balance_callback(rq);
> +
> +		/* see dispatch_pick() */
> +		if (unlikely(rq->scx.kick_sync_pending)) {
> +			rq->scx.kick_sync_pending = false;
> +			queue_balance_callback(rq, &rq->scx.kick_sync_bal_cb,
> +					       kick_sync_wait_bal_cb);
> +		}
> +	} else if (unlikely(rq->scx.flags & SCX_RQ_BAL_CB_PENDING)) {

[Severity: High]
Does this silently drop pending kick-syncs for remote sibling runqueues under
core scheduling?

Because the kick_sync_pending check is under the cpu_of(rq) ==
smp_processor_id() branch, if a sibling CPU performs the core-wide pick for
this remote runqueue, the check is skipped.

The core picker then sets rq->core_pick for this runqueue. When the kicked
sibling CPU enters __schedule(), it hits the core-scheduling fast-path and
bypasses do_pick_task_scx(). As a result, dispatch_core_pick() is never
executed locally.

Could this lead to the kick_sync_wait_bal_cb balance callback never being
queued, breaking the synchronization guarantees of scx_bpf_kick_cpu() and
leaving the BPF scheduler operating on incorrect assumptions?

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

  reply	other threads:[~2026-08-07 21:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 21:02 [PATCHSET sched_ext/for-7.2-fixes] sched_ext: Fix core scheduling Tejun Heo
2026-08-07 21:02 ` [PATCH 1/6] sched/core: Handle pick_task() releasing the rq lock Tejun Heo
2026-08-07 21:26   ` sashiko-bot
2026-08-10 11:00   ` Peter Zijlstra
2026-08-07 21:02 ` [PATCH 2/6] sched/core: Make core-sched flips wait for in-flight selections Tejun Heo
2026-08-10 11:15   ` Peter Zijlstra
2026-08-10 22:10     ` Tejun Heo
2026-08-11 16:05       ` Peter Zijlstra
2026-08-07 21:02 ` [PATCH 3/6] sched_ext: Replace SCX_RQ_BAL_KEEP with a dispatch verdict return Tejun Heo
2026-08-11  7:43   ` Andrea Righi
2026-08-12 17:06   ` [PATCH v2 " Tejun Heo
2026-08-07 21:02 ` [PATCH 4/6] sched_ext: Fix this_rq() assumptions in dispatch kfuncs Tejun Heo
2026-08-07 21:02 ` [PATCH 5/6] sched_ext: Count rq lock releases in rq->scx.lock_drop_seq Tejun Heo
2026-08-07 21:02 ` [PATCH 6/6] sched_ext: Fix rq->core_pick corruption under core scheduling Tejun Heo
2026-08-07 21:22   ` sashiko-bot [this message]
2026-08-12 17:07 ` [PATCHSET sched_ext/for-7.2-fixes] sched_ext: Fix " Tejun Heo
2026-08-12 20:25 ` 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=20260807212232.B43FF1F000E9@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