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
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to