Source-Changes-HG archive

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

[src/trunk]: src/sys/kern mi_switch: move LOCKDEBUG_BARRIER later to accomoda...



details:   https://anonhg.NetBSD.org/src/rev/6db6d172098a
branches:  trunk
changeset: 847031:6db6d172098a
user:      ad <ad%NetBSD.org@localhost>
date:      Sat Dec 07 17:36:33 2019 +0000

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

diffstat:

 sys/kern/kern_synch.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 16daa377d8ae -r 6db6d172098a sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c     Sat Dec 07 16:38:42 2019 +0000
+++ b/sys/kern/kern_synch.c     Sat Dec 07 17:36:33 2019 +0000
@@ -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 @@
        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 @@
                        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 @@
                /* 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);
        }
 



Home | Main Index | Thread Index | Old Index