From 0a3ddbf3944494eafe4f5b46a34dd699ddf695cb Mon Sep 17 00:00:00 2001 From: visa Date: Mon, 21 Mar 2022 05:45:52 +0000 Subject: [PATCH] Remove data dependency barrier from atomic_load_* functions This makes the atomic_load_* functions relaxed in terms of memory ordering. Now it should be acceptable to use these functions in assertions. The need of the data dependency barrier is conditioned to usage. The barrier is unnecessary for the control decisions that cond_wait() and refcnt_finalize() make. READ_ONCE() and SMR_PTR_GET() use the barrier so that loaded pointers would work as excepted in lock-free contexts (some Alpha CPUs have a data cache design that can cause unusual load-load reordering if not synchronized properly). OK bluhm@ --- sys/sys/atomic.h | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/sys/sys/atomic.h b/sys/sys/atomic.h index 93c0e0afab9..f6480476738 100644 --- a/sys/sys/atomic.h +++ b/sys/sys/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.8 2022/03/11 19:02:15 bluhm Exp $ */ +/* $OpenBSD: atomic.h,v 1.9 2022/03/21 05:45:52 visa Exp $ */ /* * Copyright (c) 2014 David Gwynne * Copyright (c) 2022 Alexander Bluhm @@ -201,26 +201,16 @@ atomic_sub_long_nv(volatile unsigned long *p, unsigned long v) * 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; } /* -- 2.20.1