Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch __cpu_simple_lock(9): Omit needless barriers in init.
details: https://anonhg.NetBSD.org/src/rev/f4635ad0202f
branches: trunk
changeset: 361160:f4635ad0202f
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Feb 12 17:17:53 2022 +0000
description:
__cpu_simple_lock(9): Omit needless barriers in init.
It is, and always has been, the caller's responsibility to ensure the
lock is initialized before it can be used -- otherwise the memory
could hold garbage; it is nonsensical to even attempt locking
operations on it before initialization.
So there's no need to issue explicit barriers here. The barrier
seems to have been introduced in sys/arch/alpha/alpha/lock_machdep.c
rev. 1.1 (since moved to inline asm in alpha/include/lock.h) and then
copied & pasted into several other architectures.
diffstat:
sys/arch/alpha/include/lock.h | 9 ++-------
sys/arch/hppa/include/lock.h | 4 ++--
sys/arch/ia64/include/lock.h | 3 +--
sys/arch/powerpc/include/lock.h | 3 +--
sys/arch/vax/include/lock.h | 14 ++------------
sys/arch/x86/include/lock.h | 3 +--
6 files changed, 9 insertions(+), 27 deletions(-)
diffs (123 lines):
diff -r 40a3ad087c55 -r f4635ad0202f sys/arch/alpha/include/lock.h
--- a/sys/arch/alpha/include/lock.h Sat Feb 12 17:10:20 2022 +0000
+++ b/sys/arch/alpha/include/lock.h Sat Feb 12 17:17:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.h,v 1.31 2021/04/03 14:56:13 thorpej Exp $ */
+/* $NetBSD: lock.h,v 1.32 2022/02/12 17:17:53 riastradh Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -69,12 +69,7 @@
__cpu_simple_lock_init(__cpu_simple_lock_t *alp)
{
- __asm volatile(
- "# BEGIN __cpu_simple_lock_init\n"
- " stl $31, %0 \n"
- " mb \n"
- " # END __cpu_simple_lock_init"
- : "=m" (*alp));
+ *alp = __SIMPLELOCK_UNLOCKED;
}
static __inline void
diff -r 40a3ad087c55 -r f4635ad0202f sys/arch/hppa/include/lock.h
--- a/sys/arch/hppa/include/lock.h Sat Feb 12 17:10:20 2022 +0000
+++ b/sys/arch/hppa/include/lock.h Sat Feb 12 17:17:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.h,v 1.22 2019/11/29 20:05:29 riastradh Exp $ */
+/* $NetBSD: lock.h,v 1.23 2022/02/12 17:17:53 riastradh Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -85,10 +85,10 @@
static __inline void
__cpu_simple_lock_init(__cpu_simple_lock_t *alp)
{
+
alp->csl_lock[0] = alp->csl_lock[1] =
alp->csl_lock[2] = alp->csl_lock[3] =
__SIMPLELOCK_RAW_UNLOCKED;
- __sync();
}
static __inline void
diff -r 40a3ad087c55 -r f4635ad0202f sys/arch/ia64/include/lock.h
--- a/sys/arch/ia64/include/lock.h Sat Feb 12 17:10:20 2022 +0000
+++ b/sys/arch/ia64/include/lock.h Sat Feb 12 17:17:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.h,v 1.8 2019/11/29 20:05:38 riastradh Exp $ */
+/* $NetBSD: lock.h,v 1.9 2022/02/12 17:17:53 riastradh Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -83,7 +83,6 @@
{
*lockp = __SIMPLELOCK_UNLOCKED;
- __insn_barrier();
}
static __inline int
diff -r 40a3ad087c55 -r f4635ad0202f sys/arch/powerpc/include/lock.h
--- a/sys/arch/powerpc/include/lock.h Sat Feb 12 17:10:20 2022 +0000
+++ b/sys/arch/powerpc/include/lock.h Sat Feb 12 17:17:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.h,v 1.16 2021/09/13 11:54:42 rin Exp $ */
+/* $NetBSD: lock.h,v 1.17 2022/02/12 17:17:53 riastradh Exp $ */
/*-
* Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -64,7 +64,6 @@
__cpu_simple_lock_init(__cpu_simple_lock_t *alp)
{
*alp = __SIMPLELOCK_UNLOCKED;
- __asm volatile ("sync");
}
static __inline void
diff -r 40a3ad087c55 -r f4635ad0202f sys/arch/vax/include/lock.h
--- a/sys/arch/vax/include/lock.h Sat Feb 12 17:10:20 2022 +0000
+++ b/sys/arch/vax/include/lock.h Sat Feb 12 17:17:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.h,v 1.32 2019/11/29 20:06:44 riastradh Exp $ */
+/* $NetBSD: lock.h,v 1.33 2022/02/12 17:17:53 riastradh Exp $ */
/*
* Copyright (c) 2000 Ludd, University of Lule}, Sweden.
@@ -66,17 +66,7 @@
static __inline void
__cpu_simple_lock_init(__cpu_simple_lock_t *__alp)
{
-#ifdef _HARDKERNEL
- __asm __volatile ("movl %0,%%r1;jsb Sunlock"
- : /* No output */
- : "g"(__alp)
- : "r1","cc","memory");
-#else
- __asm __volatile ("bbcci $0,%0,1f;1:"
- : /* No output */
- : "m"(*__alp)
- : "cc");
-#endif
+ *__alp = __SIMPLELOCK_UNLOCKED;
}
static __inline int __cpu_simple_lock_try(__cpu_simple_lock_t *);
diff -r 40a3ad087c55 -r f4635ad0202f sys/arch/x86/include/lock.h
--- a/sys/arch/x86/include/lock.h Sat Feb 12 17:10:20 2022 +0000
+++ b/sys/arch/x86/include/lock.h Sat Feb 12 17:17:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.h,v 1.28 2017/09/16 23:55:45 christos Exp $ */
+/* $NetBSD: lock.h,v 1.29 2022/02/12 17:17:54 riastradh Exp $ */
/*-
* Copyright (c) 2000, 2006 The NetBSD Foundation, Inc.
@@ -88,7 +88,6 @@
{
*lockp = __SIMPLELOCK_UNLOCKED;
- __insn_barrier();
}
SPINLOCK_INLINE int
Home |
Main Index |
Thread Index |
Old Index