svn commit: r331362 - head/sys/kern

Warner Losh imp at FreeBSD.org
Thu Mar 22 15:34:38 UTC 2018


Author: imp
Date: Thu Mar 22 15:34:37 2018
New Revision: 331362
URL: https://svnweb.freebsd.org/changeset/base/331362

Log:
  Drop any recursed taking of Giant once and for all at the top of
  kern_reboot(). The shutdown path is now safe to run without Giant.
  
  Discussed with: kib@
  Sponsored by: Netflix

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==============================================================================
--- head/sys/kern/kern_shutdown.c	Thu Mar 22 15:32:57 2018	(r331361)
+++ head/sys/kern/kern_shutdown.c	Thu Mar 22 15:34:37 2018	(r331362)
@@ -366,6 +366,17 @@ kern_reboot(int howto)
 {
 	static int once = 0;
 
+	/*
+	 * Normal paths here don't hold Giant, but we can wind up here
+	 * unexpectedly with it held.  Drop it now so we don't have to
+	 * drop and pick it up elsewhere. The paths it is locking will
+	 * never be returned to, and it is preferable to preclude
+	 * deadlock than to lock against code that won't ever
+	 * continue.
+	 */
+	while (mtx_owned(&Giant))
+		mtx_unlock(&Giant);
+
 #if defined(SMP)
 	/*
 	 * Bind us to the first CPU so that all shutdown code runs there.  Some


More information about the svn-src-head mailing list