svn commit: r346643 - head/sys/x86/x86

Conrad Meyer cem at FreeBSD.org
Tue Sep 3 14:08:22 UTC 2019


Author: cem
Date: Wed Apr 24 18:24:22 2019
New Revision: 346643
URL: https://svnweb.freebsd.org/changeset/base/346643

Log:
  x86: Halt non-BSP CPUs on panic IPI_STOP
  
  We may need the BSP to reboot, but we don't need any AP CPU that isn't the
  panic thread.  Any CPU landing in this routine during panic isn't the panic
  thread, so we can just detect !BSP && panic and shut down the logical core.
  
  The savings can be demonstrated in a bhyve guest with multiple cores; before
  this change, N guest threads would spin at 100% CPU.  After this change,
  only one or two threads spin (depending on if the panicing CPU was the BSP
  or not).
  
  Konstantin points out that this may break any future patches which allow
  switching ddb(4) CPUs after panic and examining CPU-local state that cannot
  be inspected remotely.  In the event that such a mechanism is incorporated,
  this behavior could be made configurable by tunable/sysctl.
  
  Reviewed by:	kib
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D20019

Modified:
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/x86/x86/mp_x86.c
==============================================================================
--- head/sys/x86/x86/mp_x86.c	Wed Apr 24 17:30:50 2019	(r346642)
+++ head/sys/x86/x86/mp_x86.c	Wed Apr 24 18:24:22 2019	(r346643)
@@ -1406,8 +1406,17 @@ cpustop_handler(void)
 	CPU_SET_ATOMIC(cpu, &stopped_cpus);
 
 	/* Wait for restart */
-	while (!CPU_ISSET(cpu, &started_cpus))
-	    ia32_pause();
+	while (!CPU_ISSET(cpu, &started_cpus)) {
+		ia32_pause();
+
+		/*
+		 * Halt non-BSP CPUs on panic -- we're never going to need them
+		 * again, and might as well save power / release resources
+		 * (e.g., overprovisioned VM infrastructure).
+		 */
+		while (__predict_false(!IS_BSP() && panicstr != NULL))
+			halt();
+	}
 
 	cpustop_handler_post(cpu);
 }




More information about the svn-src-all mailing list