Re: [PATCH RFC] Avoid memory barrier in read_seqcount() through load acquire
From: Christoph Lameter (Ampere)
Date: Tue Aug 13 2024 - 15:49:05 EST
On Tue, 13 Aug 2024, Waiman Long wrote:
Do we need a new ARCH flag? I believe barrier APIs like smp_load_acquire()
will use the full barrier for those arch'es that don't define their own
smp_load_acquire().
Well this is a load acquire instruction. The fallback of smp_load_aquire
is:
#define __smp_load_acquire(p) \
({ \
__unqual_scalar_typeof(*p) ___p1 = READ_ONCE(*p); \
compiletime_assert_atomic_type(*p); \
__smp_mb(); \
(typeof(*p))___p1; \
})
Looks like we have an acquire + barrier here.
BTW, acquire/release can be considered memory barriers too. Maybe you are
talking about preferring acquire/release barriers over read/write barriers.
Right?
Load acquire is a single instruction load that does not require full
barrier semantics for the critical section but ensures that the value is
loaded before all following. Regular barriers do not have this singe load
that isolates the critical section and sequence all loads around them.