On Tue, Mar 15, 2022 at 09:15:34AM +0000, Visa Hankala wrote:
> However, some DEC Alpha CPUs have their data caches divided into cache
> banks to improve bandwidth. These cache banks are relatively
> independent. The system maintains coherency, but bus contention can
> delay propagation of cache updates. If the loads spanned different cache
> banks, the second load could deliver data which is older than the
> initial load's value. The data dependency barrier causes an interlock
> with cache updating, ensuring causal ordering.)

The code with the membar is copied from READ_ONCE() which is copied
from Linux.  The membar_datadep_consumer() has an #ifdef __alpha__
in it.  It is only used for that case.  I don't know whether we
want to support such CPU.  But if that is the case, we need the
membar.

What do you need refcnt_read() for?  Is it only for assert?  Then
a refcnt_assert() without membar or atomic_load might be better.

bluhm

> Index: sys/sys/atomic.h
> ===================================================================
> RCS file: src/sys/sys/atomic.h,v
> retrieving revision 1.8
> diff -u -p -r1.8 atomic.h
> --- sys/sys/atomic.h  11 Mar 2022 19:02:15 -0000      1.8
> +++ sys/sys/atomic.h  15 Mar 2022 07:52:39 -0000
> @@ -201,26 +201,16 @@ atomic_sub_long_nv(volatile unsigned lon
>   * atomic_load_* - read from memory
>   */
>  
> -static inline void membar_datadep_consumer(void);
> -
>  static inline unsigned int
>  atomic_load_int(volatile unsigned int *p)
>  {
> -     unsigned int v;
> -
> -     v = *p;
> -     membar_datadep_consumer();
> -     return v;
> +     return *p;
>  }
>  
>  static inline unsigned long
>  atomic_load_long(volatile unsigned long *p)
>  {
> -     unsigned long v;
> -
> -     v = *p;
> -     membar_datadep_consumer();
> -     return v;
> +     return *p;
>  }
>  
>  /*

Reply via email to