On Tue, 17 Sep 2024, Will Deacon wrote: > > +config ARCH_HAS_ACQUIRE_RELEASE > > + bool > > + help > > + Setting ARCH_HAS_ACQUIRE_RELEASE indicates that the architecture > > + supports load acquire and release. Typically these are more effective > > + than memory barriers. Code will prefer the use of load acquire and > > + store release over memory barriers if this option is enabled. > > + > > Unsurprisingly, I'd be in favour of making this unconditional rather than > adding a new Kconfig option. Would that actually hurt any architectures > where we care about the last few shreds of performance? Other arches do not have acquire / release and will create additional barriers in the fallback implementation of smp_load_acquire. So it needs to be an arch config option. > > + if (USE_COND_LOAD_ACQUIRE) > > + return smp_cond_load_acquire((unsigned int *)&s->sequence, (s->sequence & 1) == 0); > > This looks wrong to me. > > The conditional expression passed to smp_cond_load_acquire() should be > written in terms of 'VAL', otherwise you're introducing an additional > non-atomic access to the sequence counter. Hmmm... The compiler seems to have optimized that out. Will use VAL in next rollup.