kernel/scheduler: Make invoke_scheduler atomic to skip unnecessary ICIs.

Following upon a KDL reported by atomozero, on wait-for-free-SMP-messages
on an unblock occurring with interrupts disabled.

In changing cpu_ent, move disabled to the beginning to avoid
enlarging the structure unncessarily.

On a 4-core VM, this skips around 200 sends during boot, and
over 3000 during a rebuild of HaikuDepot + mime_db (cold). On
bare metal (i3, 2x2), it skips around 150 during boot, and a bit
below 3000 during a rebuild of HaikuDepot + mime_db (over a much
longer time than in the VM, as the hardware is slower.)

Performance in the VM doesn't look much different. But this might
help in VirtualBox, or other situations where ICI latency is far
above what it should be.
This commit is contained in:
Augustin Cavalier
2026-03-17 11:25:36 -04:00
parent e53d371901
commit 19bcb3be0a
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -50,8 +50,9 @@ typedef struct cpu_topology_node {
typedef struct CACHE_LINE_ALIGN cpu_ent {
int cpu_num;
bool disabled;
// thread.c: used to force a reschedule at quantum expiration time
// used to force a reschedule at quantum expiration time
bool preempted;
timer quantum_timer;
@@ -72,8 +73,7 @@ typedef struct CACHE_LINE_ALIGN cpu_ent {
Thread* running_thread;
Thread* previous_thread;
bool invoke_scheduler;
bool disabled;
int32 invoke_scheduler;
// CPU topology information
int topology_id[CPU_TOPOLOGY_LEVELS];