git: 054ce2b03710 - main - atomic: add stub atomic_load_consume_ptr

Mateusz Guzik mjg at FreeBSD.org
Mon Jan 25 22:42:37 UTC 2021


The branch main has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=054ce2b0371042c0dbc4b3ab1d7e7795ad75d51e

commit 054ce2b0371042c0dbc4b3ab1d7e7795ad75d51e
Author:     Mateusz Guzik <mjg at FreeBSD.org>
AuthorDate: 2021-01-25 20:09:41 +0000
Commit:     Mateusz Guzik <mjg at FreeBSD.org>
CommitDate: 2021-01-25 22:40:15 +0000

    atomic: add stub atomic_load_consume_ptr
---
 sys/sys/_cscan_atomic.h | 5 +++++
 sys/sys/atomic_common.h | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/sys/sys/_cscan_atomic.h b/sys/sys/_cscan_atomic.h
index 3bd9455102b1..aed96580e1e4 100644
--- a/sys/sys/_cscan_atomic.h
+++ b/sys/sys/_cscan_atomic.h
@@ -236,6 +236,11 @@ void	kcsan_atomic_thread_fence_seq_cst(void);
 	__retptr;								\
 })
 #define	atomic_load_acq_ptr		kcsan_atomic_load_acq_ptr
+#define	atomic_load_consume_ptr(x)	({					\
+	__typeof(*x) __retptr;							\
+	__retptr = (void *)kcsan_atomic_load_acq_ptr((volatile uintptr_t *)(x));\
+	__retptr;								\
+})
 #define	atomic_readandclear_ptr		kcsan_atomic_readandclear_ptr
 #define	atomic_set_ptr			kcsan_atomic_set_ptr
 #define	atomic_set_acq_ptr		kcsan_atomic_set_acq_ptr
diff --git a/sys/sys/atomic_common.h b/sys/sys/atomic_common.h
index 4c29d132c369..48f0a8b8939c 100644
--- a/sys/sys/atomic_common.h
+++ b/sys/sys/atomic_common.h
@@ -70,4 +70,12 @@
     (*(volatile uint64_t *)(p) = (uint64_t)(v))
 #endif
 
+/*
+ * Currently all architectures provide acquire and release fences on their own,
+ * but they don't provide consume. Kludge below allows relevant code to stop
+ * openly resorting to the stronger acquire fence, to be sorted out.
+ */
+#define	atomic_load_consume_ptr(p)	\
+    ((__typeof(*p)) atomic_load_acq_ptr((uintptr_t *)p))
+
 #endif


More information about the dev-commits-src-all mailing list