Module Name: src
Committed By: riastradh
Date: Sun Feb 13 13:41:18 UTC 2022
Modified Files:
src/sys/arch/sparc/include: lock.h
Log Message:
sparc: __cpu_simple_lock membar audit.
No functional change -- comments only, to justify the absence of
barriers with reference to chapter & verse.
To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/sparc/include/lock.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/sparc/include/lock.h
diff -u src/sys/arch/sparc/include/lock.h:1.33 src/sys/arch/sparc/include/lock.h:1.34
--- src/sys/arch/sparc/include/lock.h:1.33 Fri Nov 29 20:06:34 2019
+++ src/sys/arch/sparc/include/lock.h Sun Feb 13 13:41:17 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.h,v 1.33 2019/11/29 20:06:34 riastradh Exp $ */
+/* $NetBSD: lock.h,v 1.34 2022/02/13 13:41:17 riastradh Exp $ */
/*-
* Copyright (c) 1998, 1999, 2006 The NetBSD Foundation, Inc.
@@ -118,6 +118,12 @@ __cpu_simple_lock(__cpu_simple_lock_t *a
while (*alp != __SIMPLELOCK_UNLOCKED)
/* spin */ ;
}
+
+ /*
+ * No memory barrier needed here to make this a load-acquire
+ * operation because LDSTUB already implies that. See SPARCv8
+ * Reference Manual, Appendix J.4 `Spin Locks', p. 271.
+ */
}
#endif /* __CPU_SIMPLE_LOCK_NOINLINE */
@@ -125,6 +131,10 @@ static __inline int
__cpu_simple_lock_try(__cpu_simple_lock_t *alp)
{
+ /*
+ * No memory barrier needed for LDSTUB to be a load-acquire --
+ * see __cpu_simple_lock.
+ */
return (__ldstub(alp) == __SIMPLELOCK_UNLOCKED);
}
@@ -135,6 +145,9 @@ __cpu_simple_unlock(__cpu_simple_lock_t
/*
* Insert compiler barrier to prevent instruction re-ordering
* around the lock release.
+ *
+ * No memory barrier needed because we run the kernel in TSO.
+ * If we ran the kernel in PSO, this would require STBAR.
*/
__insn_barrier();
*alp = __SIMPLELOCK_UNLOCKED;