mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* v7.4-rc2 kernel build failure when using the upstream LLVM 24 with -Wunsequenced-volatile
@ 2026-11-19 13:23 Yunseong Kim
  2026-11-19 14:13 ` Yunseong Kim
       [not found] ` <CADZ1XiZG1y=rC05L4K3_5E3FdRR3Et+V3f8gBs9tih5rPCCv_g@mail.gmail.com>
  0 siblings, 2 replies; 3+ messages in thread
From: Yunseong Kim @ 2026-11-19 13:23 UTC (permalink / raw)
  To: aaron.ballman, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Nicolas Schier, Ingo Molnar,
	Peter Zijlstra, Juri Lelli, Vincent Guittot, Steven Rostedt,
	Ben Segall, Mel Gorman, Valentin Schneider
  Cc: llvm, linux-kbuild, linux-kernel, thakis

Hi,

After https://github.com/llvm/llvm-project/pull/180955 feature
"[clang] Add check in SemaChecking for multiple unsequenced volatile accesses",
v7.4-rc2 kernel compiling with the upstream LLVM 24 was failed.

  kernel/sched/build_utility.c:86:
  kernel/sched/topology.c:2008:29: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced-volatile]
   1998 |                 .last_balance           = jiffies,
        |                                           ~~~~~~~
   1999 |                 .balance_interval       = sd_weight,
   2000 |
   2001 |                 /* 50% success rate */
   2002 |                 .newidle_call           = 512,
   2003 |                 .newidle_success        = 256,
   2004 |                 .newidle_ratio          = 512,
   2005 |                 .newidle_stamp          = now,
   2006 |
   2007 |                 .max_newidle_lb_cost    = 0,
   2008 |                 .last_decay_max_lb_cost = jiffies,
        |                                           ^
  1 error generated.


Is that mean topology code have a potential issue, or is this a compiler's
false positive? The same error message can be reproduced on the example
user space program.

  $ cat jiffies.c
  extern volatile unsigned long jiffies;

  struct sample {
      unsigned long a;
      unsigned long b;
  };

  void init(struct sample *p)
  {
      *p = (struct sample) {
          .a = jiffies,
          .b = jiffies,
      };
  }


  $ clang --version --verbose
  clang version 24.0.0git (https://github.com/yskzalloc/llvm-project.git 5d20c85f4e1b8755b655bf1782b094fb35ec48d1)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: /home/debian-sid/kcov-dataflow/llvm-project/build-upstream-check/bin

    $ clang -std=gnu11 -Werror=unsequenced-volatile -fsyntax-only jiffies.c
    jiffies.c:12:14: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced-volatile]
       11 |         .a = jiffies,
          |              ~~~~~~~
       12 |         .b = jiffies,
          |              ^
    1 error generated.


Thanks!

Best regards,
Yunseong

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: v7.4-rc2 kernel build failure when using the upstream LLVM 24 with -Wunsequenced-volatile
  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>
  1 sibling, 0 replies; 3+ messages in thread
From: Yunseong Kim @ 2026-11-19 14:13 UTC (permalink / raw)
  To: aaron.ballman, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Nicolas Schier, Ingo Molnar,
	Peter Zijlstra, Juri Lelli, Vincent Guittot, Steven Rostedt,
	Ben Segall, Mel Gorman, Valentin Schneider
  Cc: llvm, linux-kbuild, linux-kernel, thakis

Hi,

On 19/11/2026 2:23 pm, Yunseong Kim wrote:
> Hi,
> 
> After https://github.com/llvm/llvm-project/pull/180955 feature
> "[clang] Add check in SemaChecking for multiple unsequenced volatile accesses",
> v7.4-rc2 kernel compiling with the upstream LLVM 24 was failed.
> 
>   kernel/sched/build_utility.c:86:
>   kernel/sched/topology.c:2008:29: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced-volatile]
>    1998 |                 .last_balance           = jiffies,
>         |                                           ~~~~~~~
>    1999 |                 .balance_interval       = sd_weight,
>    2000 |
>    2001 |                 /* 50% success rate */
>    2002 |                 .newidle_call           = 512,
>    2003 |                 .newidle_success        = 256,
>    2004 |                 .newidle_ratio          = 512,
>    2005 |                 .newidle_stamp          = now,
>    2006 |
>    2007 |                 .max_newidle_lb_cost    = 0,
>    2008 |                 .last_decay_max_lb_cost = jiffies,
>         |                                           ^
>   1 error generated.
> 
> 
> Is that mean topology code have a potential issue, or is this a compiler's
> false positive? The same error message can be reproduced on the example
> user space program.


I didn't realize there was already a patch in progress.

  https://github.com/ClangBuiltLinux/linux/issues/2190

  https://lore.kernel.org/20261116-topology-wunsequenced-v2-1-54611119172b@kernel.org/


Many thanks!

Best regards,
Yunseong


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: v7.4-rc2 kernel build failure when using the upstream LLVM 24 with -Wunsequenced-volatile
       [not found]   ` <1795284838.9252953@f702.i.mail.ru>
@ 2026-11-21 23:39     ` Nathan Chancellor
  0 siblings, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2026-11-21 23:39 UTC (permalink / raw)
  To: Никита
	Терентьев
  Cc: Nico Weber, aaron.ballman, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Nicolas Schier, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot, Steven Rostedt, Ben Segall,
	Mel Gorman, Valentin Schneider, llvm, linux-kbuild, linux-kernel,
	Yunseong Kim

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-21 23:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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®