From 3d11dae24b959b356c2f906b3f7dcda9a4e7f771 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 19 Nov 2025 17:53:03 -0500 Subject: kern/amd64: mp: Bring up per-processor idle threads Signed-off-by: Ian Moffett --- sys/arch/amd64/cpu/mp.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sys/arch/amd64/cpu/mp.c b/sys/arch/amd64/cpu/mp.c index 7ce3a06..1fdc9f7 100644 --- a/sys/arch/amd64/cpu/mp.c +++ b/sys/arch/amd64/cpu/mp.c @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include #include @@ -370,6 +372,28 @@ cpu_lapic_cb(struct apic_header *h, size_t arg) return -1; /* Keep going */ } +static void +cpu_start_idle(void) +{ + struct process *p; + int error; + + for (size_t i = 0; i < ap_count; ++i) { + p = kalloc(sizeof(*p)); + if (p == NULL) { + panic("mp: could not allocate idle thread\n"); + } + + /* Initialize the process */ + error = process_init(p, (uintptr_t)cpu_idle, PROC_KERN); + if (error < 0) { + panic("mp: could not initialize process\n"); + } + + sched_enqueue_proc(p); + } +} + struct cpu_info * cpu_get(uint32_t index) { @@ -432,4 +456,6 @@ cpu_start_aps(struct cpu_info *ci) } else { dtrace("%d processor(s) up\n", aps_up); } + + cpu_start_idle(); } -- cgit v1.2.3