kernel/debug: Introduce arch_debug_snooze() and make use of it.

The idea is to add a facility that will use less CPU than
the loops we currently use. The default implementation just
calls spin(), which is rdtsc+pause. This already may save
some power compared to what we previously did, which was to
re-check serial ports, PS/2, etc. every single loop in
the debugger, broken up only by "pause".

Change-Id: Ie421adae5c25ad6ae0c266d1d28c2ea7b81ae465
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9603
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Augustin Cavalier
2025-08-25 20:16:16 +00:00
committed by waddlesplash
parent 6de89c6cdf
commit 2082e1b86e
9 changed files with 53 additions and 4 deletions
+2
View File
@@ -53,6 +53,8 @@ status_t arch_get_debug_variable(const char* variableName, uint64* value);
ssize_t arch_debug_gdb_get_registers(char* buffer, size_t bufferSize); ssize_t arch_debug_gdb_get_registers(char* buffer, size_t bufferSize);
void arch_debug_snooze(bigtime_t duration);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@@ -502,6 +502,13 @@ arch_get_debug_variable(const char* variableName, uint64* value)
} }
void
arch_debug_snooze(bigtime_t duration)
{
spin(duration);
}
status_t status_t
arch_debug_init(kernel_args *args) arch_debug_init(kernel_args *args)
{ {
@@ -479,6 +479,13 @@ arch_get_debug_variable(const char* variableName, uint64* value)
} }
void
arch_debug_snooze(bigtime_t duration)
{
spin(duration);
}
status_t status_t
arch_debug_init(kernel_args *args) arch_debug_init(kernel_args *args)
{ {
@@ -393,6 +393,13 @@ arch_debug_gdb_get_registers(char* buffer, size_t bufferSize)
} }
void
arch_debug_snooze(bigtime_t duration)
{
spin(duration);
}
status_t status_t
arch_debug_init(kernel_args *args) arch_debug_init(kernel_args *args)
{ {
@@ -336,6 +336,13 @@ arch_debug_gdb_get_registers(char* buffer, size_t bufferSize)
} }
void
arch_debug_snooze(bigtime_t duration)
{
spin(duration);
}
status_t status_t
arch_debug_init(kernel_args *args) arch_debug_init(kernel_args *args)
{ {
@@ -1136,11 +1136,16 @@ arch_debug_gdb_get_registers(char* buffer, size_t bufferSize)
} }
void
arch_debug_snooze(bigtime_t duration)
{
spin(duration);
}
status_t status_t
arch_debug_init(kernel_args* args) arch_debug_init(kernel_args* args)
{ {
// at this stage, the debugger command system is alive
add_debugger_command("where", &stack_trace, "Same as \"sc\""); add_debugger_command("where", &stack_trace, "Same as \"sc\"");
add_debugger_command("bt", &stack_trace, "Same as \"sc\" (as in gdb)"); add_debugger_command("bt", &stack_trace, "Same as \"sc\" (as in gdb)");
add_debugger_command("sc", &stack_trace, add_debugger_command("sc", &stack_trace,
@@ -92,6 +92,13 @@ arch_debug_get_interrupt_pc(bool* _isSyscall)
} }
void
arch_debug_snooze(bigtime_t duration)
{
spin(duration);
}
status_t status_t
arch_debug_init(kernel_args *args) arch_debug_init(kernel_args *args)
{ {
@@ -1357,6 +1357,13 @@ arch_debug_gdb_get_registers(char* buffer, size_t bufferSize)
} }
void
arch_debug_snooze(bigtime_t duration)
{
spin(duration);
}
status_t status_t
arch_debug_init(kernel_args* args) arch_debug_init(kernel_args* args)
{ {
+2 -2
View File
@@ -715,7 +715,7 @@ kgetc(void)
} }
} }
cpu_pause(); arch_debug_snooze(5000);
} }
} }
@@ -1824,7 +1824,7 @@ debug_trap_cpu_in_kdl(int32 cpu, bool returnIfHandedOver)
sCPUTrapped[cpu] = true; sCPUTrapped[cpu] = true;
while (sInDebugger != 0) { while (sInDebugger != 0) {
cpu_pause(); arch_debug_snooze(10000);
if (sHandOverKDL && sHandOverKDLToCPU == cpu) { if (sHandOverKDL && sHandOverKDLToCPU == cpu) {
if (returnIfHandedOver) if (returnIfHandedOver)