Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sparc/include sparc: __cpu_simple_lock membar audit.



details:   https://anonhg.NetBSD.org/src/rev/ae106ef1f429
branches:  trunk
changeset: 361539:ae106ef1f429
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Feb 13 13:41:17 2022 +0000

description:
sparc: __cpu_simple_lock membar audit.

No functional change -- comments only, to justify the absence of
barriers with reference to chapter & verse.

diffstat:

 sys/arch/sparc/include/lock.h |  15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diffs (43 lines):

diff -r f09d9052524a -r ae106ef1f429 sys/arch/sparc/include/lock.h
--- a/sys/arch/sparc/include/lock.h     Sun Feb 13 13:32:03 2022 +0000
+++ b/sys/arch/sparc/include/lock.h     Sun Feb 13 13:41:17 2022 +0000
@@ -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 @@
                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 @@
 __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 @@
        /*
         * 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;



Home | Main Index | Thread Index | Old Index