Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern - If concurrent calls to kern_reboot(), only let th...
details: https://anonhg.NetBSD.org/src/rev/da498dfb2ca8
branches: trunk
changeset: 1007624:da498dfb2ca8
user: ad <ad%NetBSD.org@localhost>
date: Sun Feb 23 20:06:30 2020 +0000
description:
- If concurrent calls to kern_reboot(), only let the first do the deed.
- Don't need kernel_lock for this (either OK, or suspendsched() called).
diffstat:
sys/kern/kern_reboot.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diffs (47 lines):
diff -r bde9eaac95c2 -r da498dfb2ca8 sys/kern/kern_reboot.c
--- a/sys/kern/kern_reboot.c Sun Feb 23 18:57:28 2020 +0000
+++ b/sys/kern/kern_reboot.c Sun Feb 23 20:06:30 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_reboot.c,v 1.2 2020/01/01 22:57:17 thorpej Exp $ */
+/* $NetBSD: kern_reboot.c,v 1.3 2020/02/23 20:06:30 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -33,8 +33,9 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_reboot.c,v 1.2 2020/01/01 22:57:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_reboot.c,v 1.3 2020/02/23 20:06:30 ad Exp $");
+#include <sys/atomic.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
@@ -50,7 +51,17 @@
void
kern_reboot(int howto, char *bootstr)
{
+ static lwp_t *rebooter, *l;
+ /*
+ * If already rebooting then just hang out. Allow reentry for the
+ * benfit of ddb, even if questionable. It would be better to call
+ * exit1(), but this is called from all sorts of places.
+ */
+ l = atomic_cas_ptr(&rebooter, NULL, curlwp);
+ while (l != NULL && l != curlwp) {
+ (void)kpause("reboot", true, 0, NULL);
+ }
shutting_down = 1;
/*
@@ -87,8 +98,6 @@
/*
* Not all ports use the bootstr currently.
*/
- KERNEL_LOCK(1, NULL);
kern_reboot(SCARG(uap, opt), bootstr);
- KERNEL_UNLOCK_ONE(NULL);
return (0);
}
Home |
Main Index |
Thread Index |
Old Index