From: Tejun Heo <tj@kernel.org>
To: zhidao su <soolaugust@gmail.com>
Cc: sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org,
void@manifault.com, arighi@nvidia.com, changwoo@igalia.com,
peterz@infradead.org, mingo@redhat.com,
zhidao su <suzhidao@xiaomi.com>
Subject: Re: [PATCH] sched_ext: Use READ_ONCE() for bypass_depth in scx_bypass()
Date: Mon, 23 Mar 2026 08:41:34 -1000 [thread overview]
Message-ID: <acGJXu8dZwCfFO5s@slm.duckdns.org> (raw)
In-Reply-To: <20260323111202.3960280-1-suzhidao@xiaomi.com>
Hello,
On Mon, Mar 23, 2026 at 07:12:02PM +0800, zhidao su wrote:
> In scx_bypass(), pos->bypass_depth is read under scx_sched_lock to
> update per-cpu BYPASSING flags:
>
> raw_spin_lock(&scx_sched_lock);
> scx_for_each_descendant_pre(pos, sch) {
> if (pos->bypass_depth) /* bare read */
>
> However, bypass_depth is written by inc_bypass_depth() and
> dec_bypass_depth() under scx_bypass_lock (a different lock):
>
> lockdep_assert_held(&scx_bypass_lock);
> WRITE_ONCE(sch->bypass_depth, sch->bypass_depth + 1);
>
> The read side here holds scx_sched_lock, not scx_bypass_lock, so the
It's inside scx_bypass() which is holding scx_bypass_lock throughout the
body of the function.
> two sides are protected by different locks, constituting a lockless
> concurrent access. All other read sites consistently use READ_ONCE():
>
> L1237: if (unlikely(READ_ONCE(sch->bypass_depth)))
> L4083: while (likely(!READ_ONCE(sch->bypass_depth)))
>
> Add the missing READ_ONCE() for consistency with the rest of the code
> and to make the concurrency intent explicit to KCSAN.
Plesae do not send patches to address KCSAN issues unless you can reproduce
KCSAN warnings and always attach the output of KCSAN.
Thanks.
--
tejun
prev parent reply other threads:[~2026-03-23 18:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 11:12 zhidao su
2026-03-23 18:41 ` 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=acGJXu8dZwCfFO5s@slm.duckdns.org \
--to=tj@kernel.org \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=sched-ext@lists.linux.dev \
--cc=soolaugust@gmail.com \
--cc=suzhidao@xiaomi.com \
--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®