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
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m12s
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include <libk/std.h>
|
||||
#include <libk/string.h>
|
||||
#include <m/syscall_defs.h>
|
||||
#include <mm/liballoc.h>
|
||||
#include <proc/reschedule.h>
|
||||
#include <sys/debug.h>
|
||||
#include <sys/smp.h>
|
||||
#include <sys/spin.h>
|
||||
@@ -155,9 +157,34 @@ static void amd64_intr_exception (struct saved_regs* regs) {
|
||||
regs->rbx);
|
||||
|
||||
if (regs->cs == (GDT_UCODE | 0x03)) {
|
||||
struct cpu* reschedule_cpu;
|
||||
if (proc_kill (thiscpu->proc_current, &reschedule_cpu) == PROC_NEED_RESCHEDULE)
|
||||
cpu_request_sched (reschedule_cpu);
|
||||
struct reschedule_ctx rctx = {.entries = NULL, .lock = SPIN_LOCK_INIT};
|
||||
|
||||
proc_kill (thiscpu->proc_current, &rctx);
|
||||
|
||||
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 ();
|
||||
}
|
||||
} else {
|
||||
spin ();
|
||||
}
|
||||
@@ -185,12 +212,35 @@ void amd64_intr_handler (void* stack_ptr) {
|
||||
|
||||
struct irq* irq = irq_find (regs->trap);
|
||||
|
||||
if (irq != NULL) {
|
||||
struct cpu* reschedule_cpu = NULL;
|
||||
bool reschedule = irq->func (&reschedule_cpu, irq->arg, stack_ptr);
|
||||
if (irq == NULL)
|
||||
return;
|
||||
|
||||
if (reschedule)
|
||||
cpu_request_sched (reschedule_cpu);
|
||||
struct reschedule_ctx rctx = {.entries = NULL, .lock = SPIN_LOCK_INIT};
|
||||
irq->func (irq->arg, stack_ptr, &rctx);
|
||||
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user