Module Name: src
Committed By: ad
Date: Thu Oct 5 19:28:30 UTC 2023
Modified Files:
src/sys/kern: kern_sleepq.c kern_synch.c
src/sys/rump/librump/rumpkern: sleepq.c
Log Message:
Resolve !MULTIPROCESSOR build problem with the nasty kernel lock macros.
To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/kern/kern_sleepq.c
cvs rdiff -u -r1.362 -r1.363 src/sys/kern/kern_synch.c
cvs rdiff -u -r1.25 -r1.26 src/sys/rump/librump/rumpkern/sleepq.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_sleepq.c
diff -u src/sys/kern/kern_sleepq.c:1.77 src/sys/kern/kern_sleepq.c:1.78
--- src/sys/kern/kern_sleepq.c:1.77 Wed Oct 4 20:29:18 2023
+++ src/sys/kern/kern_sleepq.c Thu Oct 5 19:28:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sleepq.c,v 1.77 2023/10/04 20:29:18 ad Exp $ */
+/* $NetBSD: kern_sleepq.c,v 1.78 2023/10/05 19:28:30 ad Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008, 2009, 2019, 2020, 2023
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.77 2023/10/04 20:29:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.78 2023/10/05 19:28:30 ad Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -222,13 +222,19 @@ sleepq_enter(sleepq_t *sq, lwp_t *l, kmu
{
int nlocks;
+ KASSERT((sq != NULL) == (mp != NULL));
+
/*
* Acquire the per-LWP mutex and lend it our sleep queue lock.
* Once interlocked, we can release the kernel lock.
*/
lwp_lock(l);
- lwp_unlock_to(l, mp);
- KERNEL_UNLOCK_ALL(NULL, &nlocks);
+ if (mp != NULL) {
+ lwp_unlock_to(l, mp);
+ }
+ if (__predict_false((nlocks = l->l_blcnt) != 0)) {
+ KERNEL_UNLOCK_ALL(NULL, NULL);
+ }
return nlocks;
}
Index: src/sys/kern/kern_synch.c
diff -u src/sys/kern/kern_synch.c:1.362 src/sys/kern/kern_synch.c:1.363
--- src/sys/kern/kern_synch.c:1.362 Wed Oct 4 20:29:18 2023
+++ src/sys/kern/kern_synch.c Thu Oct 5 19:28:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_synch.c,v 1.362 2023/10/04 20:29:18 ad Exp $ */
+/* $NetBSD: kern_synch.c,v 1.363 2023/10/05 19:28:30 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009, 2019, 2020, 2023
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.362 2023/10/04 20:29:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.363 2023/10/05 19:28:30 ad Exp $");
#include "opt_kstack.h"
#include "opt_ddb.h"
@@ -251,8 +251,7 @@ kpause(const char *wmesg, bool intr, int
if (mtx != NULL)
mutex_exit(mtx);
- lwp_lock(l);
- KERNEL_UNLOCK_ALL(NULL, &nlocks);
+ nlocks = sleepq_enter(NULL, l, NULL);
sleepq_enqueue(NULL, l, wmesg, &kpause_syncobj, intr);
error = sleepq_block(timo, intr, &kpause_syncobj, nlocks);
if (mtx != NULL)
Index: src/sys/rump/librump/rumpkern/sleepq.c
diff -u src/sys/rump/librump/rumpkern/sleepq.c:1.25 src/sys/rump/librump/rumpkern/sleepq.c:1.26
--- src/sys/rump/librump/rumpkern/sleepq.c:1.25 Wed Oct 4 20:29:18 2023
+++ src/sys/rump/librump/rumpkern/sleepq.c Thu Oct 5 19:28:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sleepq.c,v 1.25 2023/10/04 20:29:18 ad Exp $ */
+/* $NetBSD: sleepq.c,v 1.26 2023/10/05 19:28:30 ad Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sleepq.c,v 1.25 2023/10/04 20:29:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sleepq.c,v 1.26 2023/10/05 19:28:30 ad Exp $");
#include <sys/param.h>
#include <sys/condvar.h>
@@ -62,8 +62,12 @@ sleepq_enter(sleepq_t *sq, lwp_t *l, kmu
int nlocks;
lwp_lock(l);
- lwp_unlock_to(l, mp);
- KERNEL_UNLOCK_ALL(NULL, &nlocks);
+ if (mp != NULL) {
+ lwp_unlock_to(l, mp);
+ }
+ if ((nlocks = l->l_blcnt) != 0) {
+ KERNEL_UNLOCK_ALL(NULL, NULL);
+ }
return nlocks;
}