Module Name: src Committed By: ad Date: Sun Feb 23 20:06:30 UTC 2020
Modified Files: src/sys/kern: kern_reboot.c Log Message: - 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). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/kern/kern_reboot.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_reboot.c diff -u src/sys/kern/kern_reboot.c:1.2 src/sys/kern/kern_reboot.c:1.3 --- src/sys/kern/kern_reboot.c:1.2 Wed Jan 1 22:57:17 2020 +++ src/sys/kern/kern_reboot.c Sun Feb 23 20:06:30 2020 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: kern_reboot. 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 @@ sys_reboot(struct lwp *l, const struct s /* * Not all ports use the bootstr currently. */ - KERNEL_LOCK(1, NULL); kern_reboot(SCARG(uap, opt), bootstr); - KERNEL_UNLOCK_ONE(NULL); return (0); }