Module Name:    src
Committed By:   riastradh
Date:           Thu Feb 23 14:55:10 UTC 2023

Modified Files:
        src/sys/arch/alpha/include: asm.h

Log Message:
alpha: Add missing barriers in cpu_switchto.

Details in comments.

PR kern/57240

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/alpha/include/asm.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/alpha/include/asm.h
diff -u src/sys/arch/alpha/include/asm.h:1.44 src/sys/arch/alpha/include/asm.h:1.45
--- src/sys/arch/alpha/include/asm.h:1.44	Fri Sep  4 03:53:12 2020
+++ src/sys/arch/alpha/include/asm.h	Thu Feb 23 14:55:10 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: asm.h,v 1.44 2020/09/04 03:53:12 thorpej Exp $ */
+/* $NetBSD: asm.h,v 1.45 2023/02/23 14:55:10 riastradh Exp $ */
 
 /*
  * Copyright (c) 1991,1990,1989,1994,1995,1996 Carnegie Mellon University
@@ -669,10 +669,30 @@ label:	ASCIZ msg;						\
 #define	GET_CURLWP							\
 	call_pal PAL_OSF1_rdval
 
+/*
+ * Issue barriers to coordinate mutex_exit on this CPU with
+ * mutex_vector_enter on another CPU.
+ *
+ * 1. Any prior mutex_exit by oldlwp must be visible to other
+ *    CPUs before we set ci_curlwp := newlwp on this one,
+ *    requiring a store-before-store barrier.
+ *
+ * 2. ci_curlwp := newlwp must be visible on all other CPUs
+ *    before any subsequent mutex_exit by newlwp can even test
+ *    whether there might be waiters, requiring a
+ *    store-before-load barrier.
+ *
+ * See kern_mutex.c for details -- this is necessary for
+ * adaptive mutexes to detect whether the lwp is on the CPU in
+ * order to safely block without requiring atomic r/m/w in
+ * mutex_exit.
+ */
 #define	SET_CURLWP(r)							\
 	ldq	v0, L_CPU(r)					;	\
 	mov	r, a0						;	\
+	wmb	/* store-before-store XXX patch out if !MP? */	;	\
 	stq	r, CPU_INFO_CURLWP(v0)				;	\
+	mb	/* store-before-load XXX patch out if !MP? */	;	\
 	call_pal PAL_OSF1_wrval
 
 #else	/* if not MULTIPROCESSOR... */

Reply via email to