From: Kuba Piecuch <jpiecuch@google.com>
To: Tejun Heo <tj@kernel.org>
Cc: David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>,
fangqiurong <fangqiurong@kylinos.cn>,
sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] sched_ext: Fix ops_state and ops.dequeue() locking races in dispatch
Date: Wed, 25 Nov 2026 11:07:26 +0000 [thread overview]
Message-ID: <20261125110637.211132-1-jpiecuch@google.com> (raw)
In-Reply-To: <d0843faaef949300df9b51a09e36a696@kernel.org>
Hi Tejun,
On Wed, 25 Nov 2026 00:18, Tejun Heo wrote:
> On Mon, Nov 23, 2026 at 05:10:32PM +0000, Kuba Piecuch wrote:
>> @@ -1871,8 +1884,10 @@ static void scx_dispatch_enqueue(struct scx_sched *sch, struct rq *rq,
>>
>> if (unlikely(dsq->id == SCX_DSQ_INVALID)) {
>> scx_error(sch, "attempting to dispatch to a destroyed dsq");
>> - /* fall back to the global dsq */
>> raw_spin_unlock(&dsq->lock);
>> + if (rq != task_rq(p))
>> + return false;
>> + /* fall back to the global dsq */
>> dsq = find_global_dsq(sch, task_cpu(p));
>> raw_spin_lock(&dsq->lock);
>
> I don't think the task needs to go to the global DSQ here. The scheduler
> is being ejected at this point and bypass is going to cycle all its
> runnable tasks. Maybe we can just let go of the task and return, for both
> the local and remote cases, and let the abort path recover it? What the
> BPF scheduler sees after scx_error() doesn't matter as long as the
> scheduler can be ejected and all the tasks are recovered. That'd get rid
> of the bool return and the retry in finish_dispatch().
Good point. Every caller that can pass a user DSQ here (direct_dispatch(),
finish_dispatch(), and move_task_between_dsqs()) has @p on its rq's
runnable_list and can't run on an rq that scx_bypass() has already walked,
so clearing ops_state (when SCX_ENQ_CLEAR_OPSS is set) and returning after
scx_error() leaves @p to be recovered by bypass just like
SCX_EXIT_ERROR_REENQ. Will change this in v2.
> Also, can you please factor out release_dispatching_and_lock_task_rq()
> from dispatch_to_local_dsq() in a separate prep patch?
Sure, will split that out into a prep patch in v2.
Thanks!
next prev parent reply other threads:[~2026-11-25 11:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 17:10 [PATCHSET sched_ext/for-7.4-fixes] sched_ext: Fix ops_state and ops.dequeue() locking " Kuba Piecuch
2026-11-23 17:10 ` [PATCH 1/3] sched_ext: Fix ops_state and ops.dequeue() locking races " Kuba Piecuch
2026-11-25 0:18 ` Tejun Heo
2026-11-25 11:07 ` Kuba Piecuch [this message]
2026-11-23 17:10 ` [PATCH 2/3] sched_ext: Remove scx_wait_dispatching() Kuba Piecuch
2026-11-23 17:10 ` [PATCH 3/3] selftests/sched_ext: Test that ops.dequeue() runs with the task's rq locked Kuba Piecuch
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=20261125110637.211132-1-jpiecuch@google.com \
--to=jpiecuch@google.com \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=fangqiurong@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=sched-ext@lists.linux.dev \
--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®