From: Peter Zijlstra <peterz@infradead.org>
To: Tejun Heo <tj@kernel.org>
Cc: David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>,
sched-ext@lists.linux.dev, Emil Tsalapatis <emil@etsalapatis.com>,
ElXreno <elxreno@gmail.com>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 2/6] sched/core: Make core-sched flips wait for in-flight selections
Date: Mon, 10 Aug 2026 13:15:46 +0200 [thread overview]
Message-ID: <20260810111546.GV687043@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260807210221.232543-3-tj@kernel.org>
On Fri, Aug 07, 2026 at 11:02:17AM -1000, Tejun Heo wrote:
> Core scheduling's pick_next_task() operates on all sibling rqs under one
> acquisition of the shared core-wide lock. A ->pick_task() that releases the
> rq lock leaves every sibling __lock momentarily free, letting
> __sched_core_flip(false) complete mid-selection and rebind rq_lockp() under
> it. The selection resumes on the split locks, touching sibling state it no
> longer protects, and __schedule() finally releases a lock that was never
> taken while leaking the one that was.
>
> Count in-flight core-wide selections in the leader's rq->core_pick_in_flight
> and make __sched_core_flip() wait for the count to drain. The count only
> changes under the shared lock, which the flip holds while sampling, so no
> other ordering is needed. The wait can repeat while selections overlap, but
> the flip backs off between samples and flips are rare cookie-lifetime
> events.
>
> sched_core_cpu_deactivate() moves the count to the new leader - a stale copy
> left behind would bias it forever if that CPU later returns as its own
> leader.
>
> Fixes: 4c95380701f5 ("sched/ext: Fold balance_scx() into pick_task_scx()")
I'm not entirely sure this is the right commit. I suspect this was a
problem right from the beginning. This pick_next_task() always had a
prev_balance() call that could drop the locks IIRC.
Also yuck :/ this is rather prone to starvation, and it will leave the
flip spinning ad-infinitum. But yes, this is the simplest fix I suppose.
It is not like anybody is going to be toggling this on and off very
often. And if they are, they can bloody well keep the pieces.
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
next prev parent reply other threads:[~2026-08-10 11:16 UTC|newest]
Thread overview: 15+ 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-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 [this message]
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-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=20260810111546.GV687043@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=elxreno@gmail.com \
--cc=emil@etsalapatis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sched-ext@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=tj@kernel.org \
--cc=void@manifault.com \
/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
all inboxes | Powered by JetHome®