Redesign reschedule points, allow one operation to reschedule many cpus at once
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m12s

This commit is contained in:
2026-02-18 23:16:03 +01:00
parent ae0a6024da
commit f103bdd739
39 changed files with 376 additions and 223 deletions

View File

@@ -3,10 +3,13 @@
#include <amd64/mm.h>
#include <amd64/msr-index.h>
#include <amd64/msr.h>
#include <libk/list.h>
#include <libk/string.h>
#include <m/status.h>
#include <m/syscall_defs.h>
#include <mm/liballoc.h>
#include <proc/proc.h>
#include <proc/reschedule.h>
#include <sys/debug.h>
#include <sys/smp.h>
#include <syscall/syscall.h>
@@ -34,11 +37,10 @@ uintptr_t amd64_syscall_dispatch (void* stack_ptr) {
return -ST_SYSCALL_NOT_FOUND;
}
bool reschedule = false;
struct reschedule_ctx rctx = {.entries = NULL, .lock = SPIN_LOCK_INIT};
struct cpu* reschedule_cpu = NULL;
uintptr_t r = func (caller, regs, &reschedule, &reschedule_cpu, regs->rdi, regs->rsi, regs->rdx,
regs->r10, regs->r8, regs->r9);
uintptr_t r =
func (caller, regs, &rctx, regs->rdi, regs->rsi, regs->rdx, regs->r10, regs->r8, regs->r9);
caller = proc_find_pid (caller_pid);
@@ -48,8 +50,30 @@ uintptr_t amd64_syscall_dispatch (void* stack_ptr) {
spin_unlock (&caller->lock);
}
if (reschedule)
cpu_request_sched (reschedule_cpu);
bool reschedule_thiscpu = false;
spin_lock (&rctx.lock);
struct list_node_link *node, *tmp;
list_foreach (rctx.entries, node, tmp) {
struct reschedule_entry* entry = list_entry (node, struct reschedule_entry, link);
struct cpu* cpu = entry->cpu;
if (cpu != thiscpu) {
cpu_request_sched (cpu);
} else {
reschedule_thiscpu = true;
}
list_remove (rctx.entries, &entry->link);
free (entry);
}
spin_unlock (&rctx.lock);
if (reschedule_thiscpu) {
proc_sched ();
}
return r;
}