Re: [PATCH v3] sched/topology: Avoid unsequenced accesses to jiffies in sd_init()
From: Nick Desaulniers
Date: Wed Nov 25 2026 - 14:32:52 EST
On Wed, Nov 25, 2026 at 1:46 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Wed, Nov 25, 2026 at 12:23:35AM -0700, Nathan Chancellor wrote:
> > Clang's warning is ultimately pointing out that jiffies may have two
> > separate values in this initializer because it is volatile and accessed
> > twice and the order of these accesses is not specified. This could
> > result in unexpected or inconsistent behavior depending on the code
> > author's intent and whether they realized the variable was volatile or
> > not.
> >
> > As two separate accesses is not necessary here, add a local variable to
> > hold the value of jiffies before the designated initializer so that a
> > consistent value is used for initializing both members, clearing up the
> > warning.
>
> None of this tells me why we should not just disable that warning and
> get on with life.
Nathan has provided you 3 different ways to do so. (Could also do ugly
pragma's around this code; disable it for this entire source file via
-Wno-unsequenced-volatile in the Makefile, and finally this diagnostic
was forked into a group; it's now -Wunsequenced-volatile under the
-Wunsequenced group, that could go in W=1). Pick one?
I think the warning has value generally across the tree, even if this
particular single instance "isn't a bug, per se."
--
Thanks,
~Nick Desaulniers