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

From: Nathan Chancellor

Date: Thu Nov 19 2026 - 17:41:40 EST


On Wed, Nov 18, 2026 at 10:47:26AM +0100, Peter Zijlstra wrote:
> Could it be fixed by adding an explicit cast? Say:
>
> .last_balance = (unsigned long)jiffies,

No because the accesses are still unsequenced even with the cast.

> Also, the C people are daft and want to get rid of volatile,
> irrespective of its many uses, so perhaps this is a subtle act of
> sabotage or something and we should get clang to revert this weirdness.

I won't comment on C standards politics since that's far out of my
league but I don't think it is wrong or weird for clang to warn here
(this went through a lot of review upstream). I would argue it is
genuinely trying to be helpful here since as David points out down
thread, there is a potential consistency issue here. Either you want the
same value for jiffies in the initializer (in which case, use a variable
to read the value once then use that in the initializer like this patch
does) or you don't care about potentially getting two different values
from each read of jiffies (in which case, move each access out of the
initializer like my v1 did) but the way the code is currently written,
it is not clear what behavior is desirable.

I am happy to try and make the commit message better in whatever way you
see fit.

--
Cheers,
Nathan