Module Name:    src
Committed By:   ad
Date:           Sat Dec  7 17:36:33 UTC 2019

Modified Files:
        src/sys/kern: kern_synch.c

Log Message:
mi_switch: move LOCKDEBUG_BARRIER later to accomodate holding two locks
on entry.


To generate a diff of this commit:
cvs rdiff -u -r1.329 -r1.330 src/sys/kern/kern_synch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_synch.c
diff -u src/sys/kern/kern_synch.c:1.329 src/sys/kern/kern_synch.c:1.330
--- src/sys/kern/kern_synch.c:1.329	Fri Dec  6 21:36:10 2019
+++ src/sys/kern/kern_synch.c	Sat Dec  7 17:36:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_synch.c,v 1.329 2019/12/06 21:36:10 ad Exp $	*/
+/*	$NetBSD: kern_synch.c,v 1.330 2019/12/07 17:36:33 ad Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009, 2019
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.329 2019/12/06 21:36:10 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.330 2019/12/07 17:36:33 ad Exp $");
 
 #include "opt_kstack.h"
 #include "opt_dtrace.h"
@@ -525,7 +525,6 @@ mi_switch(lwp_t *l)
 	KASSERT(lwp_locked(l, NULL));
 	KASSERT(kpreempt_disabled());
 	KASSERT(mutex_owned(curcpu()->ci_schedstate.spc_mutex));
-	LOCKDEBUG_BARRIER(l->l_mutex, 1);
 
 	kstack_check_magic(l);
 
@@ -647,6 +646,9 @@ mi_switch(lwp_t *l)
 			mutex_spin_exit(spc->spc_mutex);
 		}
 
+		/* We're down to only one lock, so do debug checks. */
+		LOCKDEBUG_BARRIER(l->l_mutex, 1);
+
 		/*
 		 * Mark that context switch is going to be performed
 		 * for this LWP, to protect it from being switched
@@ -756,6 +758,8 @@ mi_switch(lwp_t *l)
 		/* Nothing to do - just unlock and return. */
 		mutex_spin_exit(spc->spc_mutex);
 		l->l_pflag &= ~LP_PREEMPTING;
+		/* We're down to only one lock, so do debug checks. */
+		LOCKDEBUG_BARRIER(l->l_mutex, 1);
 		lwp_unlock(l);
 	}
 

Reply via email to