From: Tao Cui <cui.tao@linux.dev>
To: Kuba Piecuch <jpiecuch@google.com>, Tejun Heo <tj@kernel.org>,
David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>
Cc: cui.tao@linux.dev, sched-ext@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH sched_ext/for-7.4-fixes] sched_ext: Don't route tasks to SCX before __scx_enabled is fully patched
Date: Wed, 18 Nov 2026 21:25:44 +0800 [thread overview]
Message-ID: <11f7d4ff-b3f1-4d8c-a37c-887d354596da@linux.dev> (raw)
In-Reply-To: <20261118102453.1315267-1-jpiecuch@google.com>
Hello, Kuba,
在 2026/11/18 18:24, Kuba Piecuch 写道:
> scx_root_enable_workfn() sets scx_switching_all and calls
> static_branch_enable(&__scx_enabled) before switching tasks, and
> task_should_scx() gates only on scx_enabled(). static_branch_enable()
> patches jump-label sites in address order rather than atomically:
> task_should_scx() may be patched before __schedule().
>
> If a concurrent fork or sched_setscheduler() runs in that window,
> task_should_scx() observes scx_enabled() and moves the running task
> from fair_sched_class to ext_sched_class, setting need_resched on the
> class degradation. The following __schedule() can still observe
> !scx_enabled() in next_active_class(), skip ext_sched_class, and pick
> rq->idle while the runnable SCX task is still rq->donor:
>
> WARNING: kernel/sched/ext/ext.c:3840 at put_prev_task_scx+0x405/0x7a0
> Sched_ext: enq_select_cpu (enabling+all), task: runnable_at=+0ms
> Call Trace:
> __schedule+0x5cc/0x1100
> preempt_schedule_common+0x12/0x40
> preempt_schedule_thunk+0x16/0x40
> __sched_setscheduler+0x8d8/0x920
>
> Gate task_should_scx() on a scx_task_switch_enabled flag that is set with
> release semantics only after static_branch_enable(&__scx_enabled) has
> finished patching all call sites and scx_switching_all is updated, and
> cleared on disable alongside scx_switching_all.
>
> This bug was found and the patch was written with the help of an AI
> coding assistant.
>
> Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
> Cc: stable@vger.kernel.org # v6.12+
> Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
The release/acquire gate looks right on both the
enable and disable paths.
Applied on top of 700a332c3fe3 (for-7.4-fixes HEAD) and ran 25
scx_simple load/unload cycles in qemu under a fork and
sched_setscheduler() storm. The baseline hit the reported warning on
its own 14s into the run, log below. The patched kernel went through
the identical run with zero warnings.
[ 14.225125] CYCLE-7-start
[ 14.352153] ------------[ cut here ]------------
[ 14.352157] WARNING: kernel/sched/ext/ext.c:3840 at put_prev_task_scx+0x4e4/0x750, CPU#2: storm/91
[ 14.354627] Sched_ext: simple (enabling+all), task: runnable_at=+0ms
[ 14.372849] Call Trace:
[ 14.373019] <TASK>
[ 14.373164] __schedule+0x52d/0xe60
[ 14.373395] ? bpf__sched_ext_ops_running+0x62/0xac
[ 14.373709] preempt_schedule_common+0x12/0x40
[ 14.380061] preempt_schedule_thunk+0x16/0x40
[ 14.380628] __sched_setscheduler+0x815/0x8a0
[ 14.380918] do_sched_setscheduler+0x154/0x1f0
[ 14.381220] __x64_sys_sched_setscheduler+0x1c/0x40
Tested-by: Tao Cui <cuitao@kylinos.cn>
Reviewed-by: Tao Cui <cuitao@kylinos.cn>
next prev parent reply other threads:[~2026-11-18 13:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 10:24 [PATCH sched_ext/for-7.4-fixes] sched_ext: Don't route tasks to SCX before __scx_enabled is fully patched Kuba Piecuch
2026-11-18 13:25 ` Tao Cui [this message]
2026-11-18 14:20 ` Andrea Righi
2026-11-19 8:59 ` 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=11f7d4ff-b3f1-4d8c-a37c-887d354596da@linux.dev \
--to=cui.tao@linux.dev \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=jpiecuch@google.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.