Re: [PATCH v2] sched/topology: Avoid unsequenced accesses to jiffies in sd_init()
From: David Laight
Date: Wed Nov 18 2026 - 05:04:03 EST
On Tue, 17 Nov 2026 10:39:15 -0800
Nick Desaulniers <ndesaulniers@xxxxxxxxxx> wrote:
> On Tue, Nov 17, 2026 at 10:30 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> >
> > I don't speak enough C legal to actually understand the Changelog, but
> > the actual change seems daft. Is this really needed?
A better description might be saying something about ensuring the two
jiffies values are the same.
As coded they can be different with either larger.
> I would imagine a delta of the disassembly here before/after the
> change would make it more obvious (one less volatile access, which be
> have arbitrary ordering between initializing other members).
>
> But I guess I'm also curious why jiffies is defined as volatile
> anyway? I thought the usual guidance was to use
> cast-to-volatile-qualified pointer during access, rather than declare
> as volatile?
I'm sure that guidance was based on the fact that not all accesses needed
to be volatile.
But now the tools are getting picky and needing WRITE_ONCE() as well as
READ_ONCE() and bleating about plain accesses maybe it is less relevant.
So if all access have to be volatile why not make the variable volatile?
Doesn't this initialiser also generate 'really crap code'?
IIRC it is likely to generate an on-stack structure and then do a memcpy().
David