Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: "Никита Терентьев" <svet58585@mail.ru>
Cc: Nico Weber <thakis@chromium.org>,
	aaron.ballman@intel.com,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Nicolas Schier <nsc@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittoteggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <kprateek.nayak@amd.com>,
	llvm@lists.linux.dev, linux-kbuild@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Yunseong Kim <yunseong.kim@est.tech>
Subject: Re: v7.4-rc2 kernel build failure when using the upstream LLVM 24 with -Wunsequenced-volatile
Date: Sat, 21 Nov 2026 16:39:36 -0700	[thread overview]
Message-ID: <20261121233936.GA2627970@ax162> (raw)
In-Reply-To: <1795284838.9252953@f702.i.mail.ru>

On Sat, Nov 21, 2026 at 09:13:58PM +0300, Никита Терентьев wrote:
> By standard UB occur for unsequenced order, not unspecified.

Ah fair, I had conflated those.

> But despite the fact that this is not UB - fields a and b really may
> be different, moreover, according to the standard there is no
> guarantee that a less than is equal to b, and this is most likely not
> the expected result. So I would say that this is incorrect wording
> but this is a correctly issued warning.

Yeah, I think it is definitely ambiguous what someone might be expecting
there: are they expecting the same value or are they okay with the two
separate accesses being different values? It is not always obvious if
the variable is marked as volatile or not.

> I'm not sure whether it's worth changing the wording or turning off
> the warning in this case still.

Maybe a note could be attached to the warning explaining the accesses
may result in different values and offering a small hint how to silence
it?

I do think this is a good warning and I would love to avoid turning it
off, even temporarily. I sent 11 patches for the instances that appeared
in the kernel tree.

Five have been merged into mainline:

  https://git.kernel.org/linus/c3f98ff6309a29979e1867bc3c9d4172755ca122 ("rcu/nocb: Avoid unsequenced accesses to jiffies in show_rcu_nocb_state()")
  https://git.kernel.org/linus/728a2abd15a767f662a44030931ea7b2959b4e88 ("mptcp: Avoid unsequenced accesses to jiffies in mptcp_reset_tout_timer()")
  https://git.kernel.org/linus/5ec918f8d66a0311c52cc767ade67e7019beb176 ("net: microchip: encx24j600: Avoid unsequenced accesses to jiffies in encx24j600_tx()")
  https://git.kernel.org/linus/695d0824cb6b27ff1a1cdeabb2d5138f00b15251 ("qca_spi: Avoid unsequenced accesses to jiffies in qcaspi_netdev_tx_timeout()")
  https://git.kernel.org/linus/9ea01307e6c824eb0b8934d95d52bbacae17887d ("powerpc/xmon: Avoid unsequenced accesses to tsk in show_task()")

Two are pending in maintainers trees:

  https://git.kernel.org/axboe/c/ae1171f38098098e88c13c38e462d27babb50038 ("blk-throttle: Avoid unsequenced accesses to jiffies in throtl_schedule_pending_timer()")
  https://github.com/evdenis/linux-floppy/commit/c1a8feb71ba8613108b212c705a48e0e136d8c3a ("floppy: Avoid unsequenced accesses to jiffies in show_floppy()")

Four are pending on the mailing list:

  https://lore.kernel.org/20261116-topology-wunsequenced-v2-1-54611119172b@kernel.org/ ("sched/topology: Avoid unsequenced accesses to jiffies in sd_init()")
  https://lore.kernel.org/20261114-lkdtm-bugs-wunsequenced-v1-1-b24f15ce1328@kernel.org/ ("lkdtm/bugs: Remove volatile from element_count")
  https://lore.kernel.org/20261114-lkdtm-usercopy-wunsequenced-v1-1-d9f288701932@kernel.org/ ("lkdtm/usercopy: Avoid unsequenced accesses to cache_size in lkdtm_usercopy_init()")
  https://lore.kernel.org/20261115-ceph-wunsequenced-v1-1-6910c560ba9b@kernel.org/ ("libceph: Avoid unsequenced accesses to jiffies in dump_linger_request()")

If the four linger for too long, we can consider moving the warning to
W=1 but it will still bother a decent number of people, so it would be
better to just get them fixed quickly.

-- 
Cheers,
Nathan

      parent reply	other threads:[~2026-11-21 23:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 13:23 v7.4-rc2 kernel build failure when using the upstream LLVM 24 with -Wunsequenced-volatile Yunseong Kim
2026-11-19 14:13 ` Yunseong Kim
     [not found] ` <CADZ1XiZG1y=rC05L4K3_5E3FdRR3Et+V3f8gBs9tih5rPCCv_g@mail.gmail.com>
     [not found]   ` <1795284838.9252953@f702.i.mail.ru>
2026-11-21 23:39     ` Nathan Chancellor [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=20261121233936.GA2627970@ax162 \
    --to=nathan@kernel.org \
    --cc=aaron.ballman@intel.com \
    --cc=bsegall@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=justinstitt@google.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=ndesaulniers@google.com \
    --cc=nsc@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=svet58585@mail.ru \
    --cc=thakis@chromium.org \
    --cc=vincent.guittoteggemann@arm.com \
    --cc=yunseong.kim@est.tech \
    /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