Re: [PATCH v3] sched/topology: Avoid unsequenced accesses to jiffies in sd_init()

From: Peter Zijlstra

Date: Thu Nov 26 2026 - 07:28:10 EST


On Thu, Nov 26, 2026 at 01:08:09PM +0100, Peter Zijlstra wrote:
> On Thu, Nov 26, 2026 at 12:50:32PM +0100, Peter Zijlstra wrote:

> > I just don't understand any of this. Perhaps I'm being super dense, but
> > calling this UB is utterly stupid IMO. It is trivial to define what
> > should happen here and make the compiler do it, although perhaps it is
> > not what people expect -- but at that point you can have a warning about
> > performance, rather than it being UB.
> >
> > Most all of this is me being distrustful towards the C committee about
> > volatile; they hate it while we live by it.
> >
> > But I really don't see the difference between two jiffie reads in an
> > initializer vs two jiffie reads in random code. Its just two reads that
> > cannot be fused, big deal.
> >
> > So they're making a big deal out of the unsequenced thing; but at the
> > same time they're eroding actual sequence points; I mean WTF ?!
> >
> > So function calls used to be a sequence point; but then they allowed
> > auto inlining (without the use of the inline keyword), and guess what?
> > An inlined function is explicitly not a sequence point.
> >
> > So they cannot be both concerned about sequence *and* erode sequence.
> >
> > All of this just sounds like a whole pile of wankery without actual
> > merit.
> >
> > Also; the purported justification of UB has always been room for
> > optimization, but volatile is the anti-thesis of that, it explicitly
> > does not allow optimization. Marking something with volatile as UB is
> > just batshit.
> >
> > I mean, I suppose I can apply the patch, but I'm not buying any of it.
> > This is not an improvement, it actively makes clang worse!
>
> So, if we hide this evil volatile in an external function call; then the
> C frontend will not see this most evil of UB. If we then LTO these
> objects together, the optimizer will happily merge it all back together
> again.
>
> There is no spoon^WUB.

Further idiocy; the only case where it would actually matter is with
MMIO; and there the multi register case is far more interesting than the
single register case. However, the C language is very specific about
only declaring the single object multiple times UB.

The more I look at this; the less sense it makes.