From: Tejun Heo <tj@kernel.org>
To: liwanwu <liwanwu@kylinos.cn>
Cc: Andrea Righi <arighi@nvidia.com>,
David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>,
Emil Tsalapatis <emil@etsalapatis.com>,
sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] sched_ext: Reject NMI calls to lock-taking kfuncs
Date: Wed, 02 Sep 2026 11:51:50 -1000 [thread overview]
Message-ID: <d84b31727f04e1ed0d40042ba1c09e61@kernel.org> (raw)
In-Reply-To: <1d5f2636-a5e3-4b67-bbb9-12922fa0d804@kylinos.cn>
Hello,
On Wed, Sep 02, 2026 at 09:48:28PM +0800, liwanwu wrote:
> Three "any"-category kfuncs read scx_locked_rq() on their success path
> and treat a non-NULL return as "the rq lock is already held by me",
> which a false positive under NMI turns into either a data race or a
> wrong result:
Let's add the in_nmi() test to scx_locked_rq() so that it returns NULL from
NMI. That sends all three down their unlocked paths.
> pick_idle_cpu_from_online_nodes() (kernel/sched/ext/idle.c:151), which
> writes the per-CPU nodemask per_cpu_unvisited (idle.c:146) under only
> preempt_disable(). preempt_disable() does not mask NMIs, so an NMI that
> lands on a CPU whose interrupted context is mid-way through that loop
> clobbers the scratch nodemask the interrupted context is still
> iterating.
That probably needs to be irqsave'd. preempt_disable() doesn't mask IRQs
either and the idle kfuncs can be called from IRQ-enabled contexts. As for
NMI, if someone is calling pick_idle from NMI, they're asking for it. As
long as the machine doesn't crash, it doesn't matter.
Thanks.
--
tejun
prev parent reply other threads:[~2026-09-02 21:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 9:56 [PATCH] " Wanwu Li
2026-09-01 19:51 ` Andrea Righi
2026-09-01 20:13 ` Tejun Heo
2026-09-01 20:28 ` Andrea Righi
2026-09-01 21:16 ` Tejun Heo
2026-09-02 2:31 ` [PATCH v2] " Wanwu Li
2026-09-02 6:44 ` Tejun Heo
2026-09-02 9:36 ` [PATCH v3] " Wanwu Li
2026-09-02 23:05 ` Tejun Heo
2026-09-03 1:46 ` liwanwu
2026-09-02 13:48 ` [PATCH v2] " liwanwu
2026-09-02 21:51 ` Tejun Heo [this message]
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=d84b31727f04e1ed0d40042ba1c09e61@kernel.org \
--to=tj@kernel.org \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=emil@etsalapatis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liwanwu@kylinos.cn \
--cc=sched-ext@lists.linux.dev \
--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®