From 8df3d6e8b525643be21c42fb03d8be5de994e95e Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 29 Nov 2019 19:16:40 +0000 Subject: [PATCH 1/9] Nix mb_* on alpha. --- sys/arch/alpha/include/lock.h | 19 ------------------- sys/arch/alpha/include/mutex.h | 4 ++-- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/sys/arch/alpha/include/lock.h b/sys/arch/alpha/include/lock.h index 03fad5d2385a..a86584df33ab 100644 --- a/sys/arch/alpha/include/lock.h +++ b/sys/arch/alpha/include/lock.h @@ -174,23 +174,4 @@ do { \ #define SPINLOCK_BACKOFF_HOOK (void)nullop((void *)0) #endif /* MULTIPROCESSOR */ -static __inline void -mb_read(void) -{ - __asm __volatile("mb" : : : "memory"); -} - -static __inline void -mb_write(void) -{ - /* XXX wmb */ - __asm __volatile("mb" : : : "memory"); -} - -static __inline void -mb_memory(void) -{ - __asm __volatile("mb" : : : "memory"); -} - #endif /* _ALPHA_LOCK_H_ */ diff --git a/sys/arch/alpha/include/mutex.h b/sys/arch/alpha/include/mutex.h index d8ffa8aaa060..a8238d626fee 100644 --- a/sys/arch/alpha/include/mutex.h +++ b/sys/arch/alpha/include/mutex.h @@ -60,8 +60,8 @@ struct kmutex { #define __HAVE_SIMPLE_MUTEXES 1 #define __HAVE_MUTEX_STUBS 1 -#define MUTEX_RECEIVE(mtx) mb_read() -#define MUTEX_GIVE(mtx) mb_memory() +#define MUTEX_RECEIVE(mtx) __asm __volatile("mb" : : : "memory") +#define MUTEX_GIVE(mtx) __asm __volatile("mb" : : : "memory") #define MUTEX_CAS(p, o, n) _lock_cas((p), (o), (n)) From 51bb5a61d7cafd1fe298d6976e2ba6a85eb0b57b Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 29 Nov 2019 19:20:06 +0000 Subject: [PATCH 2/9] Nix mb_* on arm. --- sys/arch/arm/include/lock.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sys/arch/arm/include/lock.h b/sys/arch/arm/include/lock.h index f1147ab0da3b..7f9d93f212a1 100644 --- a/sys/arch/arm/include/lock.h +++ b/sys/arch/arm/include/lock.h @@ -66,11 +66,8 @@ __cpu_simple_lock_set(__cpu_simple_lock_t *__ptr) } #ifdef _KERNEL +/* XXX Formerly included for obsolete mb_* API, maybe no longer needed. */ #include - -#define mb_read drain_writebuf /* in cpufunc.h */ -#define mb_write drain_writebuf /* in cpufunc.h */ -#define mb_memory drain_writebuf /* in cpufunc.h */ #endif #ifdef _ARM_ARCH_6 From b9af980d4ab11f5b06fabe14e0026158237a4597 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 29 Nov 2019 19:22:20 +0000 Subject: [PATCH 3/9] Nix mb_* on hppa. --- sys/arch/hppa/include/lock.h | 18 ------------------ sys/arch/hppa/include/mutex.h | 4 ++-- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/sys/arch/hppa/include/lock.h b/sys/arch/hppa/include/lock.h index 94e4b7f2ffd5..ed895a358189 100644 --- a/sys/arch/hppa/include/lock.h +++ b/sys/arch/hppa/include/lock.h @@ -141,22 +141,4 @@ __cpu_simple_lock_clear(__cpu_simple_lock_t *alp) *__aptr = __SIMPLELOCK_RAW_UNLOCKED; } -static __inline void -mb_read(void) -{ - __sync(); -} - -static __inline void -mb_write(void) -{ - __sync(); -} - -static __inline void -mb_memory(void) -{ - __sync(); -} - #endif /* _HPPA_LOCK_H_ */ diff --git a/sys/arch/hppa/include/mutex.h b/sys/arch/hppa/include/mutex.h index a7b5435c6e07..a31d9cfbabff 100644 --- a/sys/arch/hppa/include/mutex.h +++ b/sys/arch/hppa/include/mutex.h @@ -99,9 +99,9 @@ MUTEX_OWNED(uintptr_t owner) static inline int MUTEX_SET_WAITERS(struct kmutex *mtx, uintptr_t owner) { - mb_write(); + __sync(); /* formerly mb_read */ mtx->mtx_waiters = 1; - mb_memory(); + __sync(); /* formerly mb_memory */ return mtx->mtx_owner != MUTEX_ADAPTIVE_UNOWNED; } From 27813b88b9710f9e4f5882320000ffe102f8749b Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 29 Nov 2019 19:23:01 +0000 Subject: [PATCH 4/9] Nix mb_* on ia64. --- sys/arch/ia64/include/lock.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/sys/arch/ia64/include/lock.h b/sys/arch/ia64/include/lock.h index cac15f58065b..d283807610ac 100644 --- a/sys/arch/ia64/include/lock.h +++ b/sys/arch/ia64/include/lock.h @@ -116,24 +116,6 @@ __cpu_simple_unlock(__cpu_simple_lock_t *lockp) *lockp = __SIMPLELOCK_UNLOCKED; } -static __inline void -mb_read(void) -{ - __asm __volatile("mf \n" ::: "memory"); -} - -static __inline void -mb_write(void) -{ - __asm __volatile("mf \n" ::: "memory"); -} - -static __inline void -mb_memory(void) -{ - __asm __volatile("mf \n" ::: "memory"); -} - static __inline void ia64_pause(void) { From 5456c0f600ad7e1b951f3925be6bce89edc2a156 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 29 Nov 2019 19:24:14 +0000 Subject: [PATCH 5/9] Nix mb_* on m68k. --- sys/arch/m68k/include/lock.h | 18 ------------------ sys/arch/m68k/include/mutex.h | 4 ++-- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/sys/arch/m68k/include/lock.h b/sys/arch/m68k/include/lock.h index 445d2b10df93..55dd088288be 100644 --- a/sys/arch/m68k/include/lock.h +++ b/sys/arch/m68k/include/lock.h @@ -101,22 +101,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t *alp) *alp = __SIMPLELOCK_UNLOCKED; } -static __inline void -mb_read(void) -{ - __asm volatile("" : : : "memory"); -} - -static __inline void -mb_write(void) -{ - __asm volatile("" : : : "memory"); -} - -static __inline void -mb_memory(void) -{ - __asm volatile("" : : : "memory"); -} - #endif /* _M68K_LOCK_H_ */ diff --git a/sys/arch/m68k/include/mutex.h b/sys/arch/m68k/include/mutex.h index 1a7ee0cdc9b5..86c5a09e5426 100644 --- a/sys/arch/m68k/include/mutex.h +++ b/sys/arch/m68k/include/mutex.h @@ -62,8 +62,8 @@ struct kmutex { #define __HAVE_SIMPLE_MUTEXES 1 #define __HAVE_MUTEX_STUBS 1 -#define MUTEX_RECEIVE(mtx) mb_read() -#define MUTEX_GIVE(mtx) mb_memory() +#define MUTEX_RECEIVE(mtx) __insn_barrier() +#define MUTEX_GIVE(mtx) __insn_barrier() #define MUTEX_CAS(p, o, n) (atomic_cas_uint((p), (o), (n)) == (o)) From daaff577192dd5c6e2eddc5f25201e31cadba25c Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 29 Nov 2019 19:28:29 +0000 Subject: [PATCH 6/9] Nix mb_* on powerpc. --- sys/arch/powerpc/include/lock.h | 18 ------------------ sys/arch/powerpc/include/mutex.h | 4 ++-- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/sys/arch/powerpc/include/lock.h b/sys/arch/powerpc/include/lock.h index 35d098d90e3a..005a0b6e200d 100644 --- a/sys/arch/powerpc/include/lock.h +++ b/sys/arch/powerpc/include/lock.h @@ -120,22 +120,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t *alp) *alp = __SIMPLELOCK_UNLOCKED; } -static __inline void -mb_read(void) -{ - __asm volatile ("isync" ::: "memory"); -} - -static __inline void -mb_write(void) -{ - __asm volatile ("sync" ::: "memory"); -} - -static __inline void -mb_memory(void) -{ - __asm volatile ("sync" ::: "memory"); -} - #endif /* _POWERPC_LOCK_H_ */ diff --git a/sys/arch/powerpc/include/mutex.h b/sys/arch/powerpc/include/mutex.h index b949dcad0c48..df96cd9b0a1c 100644 --- a/sys/arch/powerpc/include/mutex.h +++ b/sys/arch/powerpc/include/mutex.h @@ -61,8 +61,8 @@ struct kmutex { #define __HAVE_SIMPLE_MUTEXES 1 #define __HAVE_MUTEX_STUBS 1 -#define MUTEX_RECEIVE(mtx) mb_read() -#define MUTEX_GIVE(mtx) mb_memory() +#define MUTEX_RECEIVE(mtx) __asm __volatile("isync" ::: "memory") +#define MUTEX_GIVE(mtx) __asm __volatile("sync" ::: "memory") #define MUTEX_CAS(p, o, n) _lock_cas((p), (o), (n)) From e8e9bbecc18eaa652cc73bff97bb5f9918949645 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 29 Nov 2019 19:29:24 +0000 Subject: [PATCH 7/9] Nix mb_* on sh3. --- sys/arch/sh3/include/lock.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/sys/arch/sh3/include/lock.h b/sys/arch/sh3/include/lock.h index b1dc9115e8b7..6fa6a2235bca 100644 --- a/sys/arch/sh3/include/lock.h +++ b/sys/arch/sh3/include/lock.h @@ -110,22 +110,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t *alp) *alp = __SIMPLELOCK_UNLOCKED; } -static __inline void -mb_read(void) -{ - __asm volatile("" : : : "memory"); -} - -static __inline void -mb_write(void) -{ - __asm volatile("" : : : "memory"); -} - -static __inline void -mb_memory(void) -{ - __asm volatile("" : : : "memory"); -} - #endif /* !_SH3_LOCK_H_ */ From 1e2f5b47d48ec5d26bf3dc15d6f9a787add41a5d Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 29 Nov 2019 19:35:13 +0000 Subject: [PATCH 8/9] Nix mb_* on sparc and sparc64. --- sys/arch/sparc/include/lock.h | 42 -------------------------------- sys/arch/sparc64/include/mutex.h | 6 ++++- 2 files changed, 5 insertions(+), 43 deletions(-) diff --git a/sys/arch/sparc/include/lock.h b/sys/arch/sparc/include/lock.h index dc326b62f714..53649449fdd4 100644 --- a/sys/arch/sparc/include/lock.h +++ b/sys/arch/sparc/include/lock.h @@ -140,46 +140,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t *alp) *alp = __SIMPLELOCK_UNLOCKED; } -#if defined(__sparc_v9__) -static __inline void -mb_read(void) -{ - __asm __volatile("membar #LoadLoad" : : : "memory"); -} - -static __inline void -mb_write(void) -{ - __asm __volatile("" : : : "memory"); -} - -static __inline void -mb_memory(void) -{ - __asm __volatile("membar #MemIssue" : : : "memory"); -} -#else /* __sparc_v9__ */ -static __inline void -mb_read(void) -{ - static volatile int junk; - __asm volatile("st %%g0,[%0]" - : - : "r" (&junk) - : "memory"); -} - -static __inline void -mb_write(void) -{ - __insn_barrier(); -} - -static __inline void -mb_memory(void) -{ - mb_read(); -} -#endif /* __sparc_v9__ */ - #endif /* _MACHINE_LOCK_H */ diff --git a/sys/arch/sparc64/include/mutex.h b/sys/arch/sparc64/include/mutex.h index 25587521cf96..ce5c0d400603 100644 --- a/sys/arch/sparc64/include/mutex.h +++ b/sys/arch/sparc64/include/mutex.h @@ -55,7 +55,11 @@ struct kmutex { #define __HAVE_MUTEX_STUBS 1 #define __HAVE_SIMPLE_MUTEXES 1 -#define MUTEX_RECEIVE(mtx) mb_read() +/* + * XXX Should this be LoadLoad|LoadStore, or does the assumption of a + * preceding atomic r/m/w operation obviate the need for that? + */ +#define MUTEX_RECEIVE(mtx) __asm __volatile("membar #LoadLoad" : : : "memory") /* * MUTEX_GIVE: no memory barrier required, as _lock_cas() will take care of it. From fbc7b5a1ce63ca81182f50e341b4c4030504f129 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 29 Nov 2019 19:36:16 +0000 Subject: [PATCH 9/9] Nix mb_* on vax. --- sys/arch/vax/include/lock.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/sys/arch/vax/include/lock.h b/sys/arch/vax/include/lock.h index adaf2088c3b3..d5bfecbfca2e 100644 --- a/sys/arch/vax/include/lock.h +++ b/sys/arch/vax/include/lock.h @@ -160,15 +160,4 @@ do { \ } while (/*CONSTCOND*/0) #endif /* MULTIPROCESSOR */ -static __inline void mb_read(void); -static __inline void -mb_read(void) -{ -} - -static __inline void mb_write(void); -static __inline void -mb_write(void) -{ -} #endif /* _VAX_LOCK_H_ */