Drop and reacquire the kernel lock in the vfs_shutdown and "cold"
authormikeb <mikeb@openbsd.org>
Tue, 12 May 2015 09:30:35 +0000 (09:30 +0000)
committermikeb <mikeb@openbsd.org>
Tue, 12 May 2015 09:30:35 +0000 (09:30 +0000)
portions of msleep and tsleep to give interrupts a chance to run
on other CPUs.

Tweak and OK kettenis

sys/kern/kern_synch.c
sys/kern/vfs_subr.c

index e438f0d..7a49c35 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: kern_synch.c,v 1.120 2015/05/07 18:30:27 mikeb Exp $  */
+/*     $OpenBSD: kern_synch.c,v 1.121 2015/05/12 09:30:35 mikeb Exp $  */
 /*     $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
 
 /*
@@ -104,6 +104,9 @@ tsleep(const volatile void *ident, int priority, const char *wmesg, int timo)
 {
        struct sleep_state sls;
        int error, error1;
+#ifdef MULTIPROCESSOR
+       int hold_count;
+#endif
 
        KASSERT((priority & ~(PRIMASK | PCATCH)) == 0);
 
@@ -121,6 +124,12 @@ tsleep(const volatile void *ident, int priority, const char *wmesg, int timo)
                 */
                s = splhigh();
                splx(safepri);
+#ifdef MULTIPROCESSOR
+               if (__mp_lock_held(&kernel_lock)) {
+                       hold_count = __mp_release_all(&kernel_lock);
+                       __mp_acquire_count(&kernel_lock, hold_count);
+               }
+#endif
                splx(s);
                return (0);
        }
@@ -150,6 +159,9 @@ msleep(const volatile void *ident, struct mutex *mtx, int priority,
 {
        struct sleep_state sls;
        int error, error1, spl;
+#ifdef MULTIPROCESSOR
+       int hold_count;
+#endif
 
        KASSERT((priority & ~(PRIMASK | PCATCH | PNORELOCK)) == 0);
        KASSERT(mtx != NULL);
@@ -164,6 +176,12 @@ msleep(const volatile void *ident, struct mutex *mtx, int priority,
                spl = MUTEX_OLDIPL(mtx);
                MUTEX_OLDIPL(mtx) = safepri;
                mtx_leave(mtx);
+#ifdef MULTIPROCESSOR
+               if (__mp_lock_held(&kernel_lock)) {
+                       hold_count = __mp_release_all(&kernel_lock);
+                       __mp_acquire_count(&kernel_lock, hold_count);
+               }
+#endif
                if ((priority & PNORELOCK) == 0) {
                        mtx_enter(mtx);
                        MUTEX_OLDIPL(mtx) = spl;
index 1d02681..2c1da15 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vfs_subr.c,v 1.230 2015/03/14 03:38:51 jsg Exp $      */
+/*     $OpenBSD: vfs_subr.c,v 1.231 2015/05/12 09:30:35 mikeb Exp $    */
 /*     $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $   */
 
 /*
@@ -1614,6 +1614,9 @@ vfs_syncwait(int verbose)
        struct buf *bp;
        int iter, nbusy, dcount, s;
        struct proc *p;
+#ifdef MULTIPROCESSOR
+       int hold_count;
+#endif
 
        p = curproc? curproc : &proc0;
        sys_sync(p, (void *)0, (register_t *)0);
@@ -1648,7 +1651,17 @@ vfs_syncwait(int verbose)
                        break;
                if (verbose)
                        printf("%d ", nbusy);
+#ifdef MULTIPROCESSOR
+               if (__mp_lock_held(&kernel_lock))
+                       hold_count = __mp_release_all(&kernel_lock);
+               else
+                       hold_count = 0;
+#endif
                DELAY(40000 * iter);
+#ifdef MULTIPROCESSOR
+               if (hold_count)
+                       __mp_acquire_count(&kernel_lock, hold_count);
+#endif
        }
 
        return nbusy;