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
This commit is contained in:
Conrad Meyer 2019-04-24 18:24:22 +00:00
parent a07067ea3f
commit f1498d7aa3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=346643

View File

@ -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);
}