kernel/debug: Invoke cpu_pause in trap_cpu_in_kdl.

This is the loop that runs on all CPUs besides the one
actually running the kernel debugger. It's functionally
a spin-loop around a few different variables, and so it
should be safe to use cpu_pause() here, just as real
spinlocks do.

(cpu_pause() just runs a "pause" or equivalent instruction,
it doesn't use the CPU-idle modules, which indeed may be
unsafe to use in KDL.)

A glance at FreeBSD seems to indicate they also do this
when their kernel debugger is active.

Seriously improves power consumption while KDL is active:
even running in a VM with only a few cores, there would be
obvious fan spin-up when entering KDL. After this change,
there's barely any at all (while overall CPU usage % remains
basically identical.)
This commit is contained in:
Augustin Cavalier 2023-09-23 14:07:17 -04:00
parent a72ea36f95
commit d0c34f9331

View File

@ -1811,6 +1811,8 @@ debug_trap_cpu_in_kdl(int32 cpu, bool returnIfHandedOver)
sCPUTrapped[cpu] = true;
while (sInDebugger != 0) {
cpu_pause();
if (sHandOverKDL && sHandOverKDLToCPU == cpu) {
if (returnIfHandedOver)
break;