Fix CPU load balancer bugs, scheduling points support for remote CPUs
All checks were successful
Build documentation / build-and-deploy (push) Successful in 28s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 28s
This commit is contained in:
@@ -122,15 +122,16 @@ struct proc* proc_find_pid (int pid) {
|
||||
return proc;
|
||||
}
|
||||
|
||||
void proc_register (struct proc* proc, struct cpu* cpu1) {
|
||||
spin_lock_ctx_t ctxcpu, ctxprtr;
|
||||
bool proc_register (struct proc* proc, struct cpu** reschedule_cpu) {
|
||||
spin_lock_ctx_t ctxcpu, ctxprtr, ctxpr;
|
||||
|
||||
proc->cpu = cpu1 != NULL ? cpu1 : cpu_find_lightest ();
|
||||
|
||||
struct cpu* cpu = proc->cpu;
|
||||
struct cpu* cpu = *reschedule_cpu != NULL ? *reschedule_cpu : cpu_find_lightest ();
|
||||
|
||||
spin_lock (&proc_tree_lock, &ctxprtr);
|
||||
spin_lock (&cpu->lock, &ctxcpu);
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
|
||||
proc->cpu = cpu;
|
||||
|
||||
rbtree_insert (struct proc, &proc_tree, &proc->proc_tree_link, proc_tree_link, pid);
|
||||
|
||||
@@ -139,8 +140,13 @@ void proc_register (struct proc* proc, struct cpu* cpu1) {
|
||||
if (cpu->proc_current == NULL)
|
||||
cpu->proc_current = proc;
|
||||
|
||||
spin_unlock (&proc_tree_lock, &ctxprtr);
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&cpu->lock, &ctxcpu);
|
||||
spin_unlock (&proc_tree_lock, &ctxprtr);
|
||||
|
||||
*reschedule_cpu = cpu;
|
||||
|
||||
return PROC_NEED_RESCHEDULE;
|
||||
}
|
||||
|
||||
/* caller holds cpu->lock */
|
||||
@@ -237,27 +243,32 @@ void proc_sched (void) {
|
||||
}
|
||||
}
|
||||
|
||||
void proc_kill (struct proc* proc) {
|
||||
bool proc_kill (struct proc* proc, struct cpu** reschedule_cpu) {
|
||||
spin_lock_ctx_t ctxpr, ctxcpu;
|
||||
struct cpu* cpu = proc->cpu;
|
||||
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
atomic_store (&proc->state, PROC_DEAD);
|
||||
proc->cpu = NULL;
|
||||
struct cpu* cpu = proc->cpu;
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
|
||||
spin_lock (&cpu->lock, &ctxcpu);
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
|
||||
atomic_store (&proc->state, PROC_DEAD);
|
||||
proc->cpu = NULL;
|
||||
|
||||
list_remove (cpu->proc_run_q, &proc->cpu_run_q_link);
|
||||
atomic_fetch_sub (&cpu->proc_run_q_count, 1);
|
||||
if (cpu->proc_current == proc)
|
||||
cpu->proc_current = NULL;
|
||||
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&cpu->lock, &ctxcpu);
|
||||
|
||||
DEBUG ("killed PID %d\n", proc->pid);
|
||||
|
||||
cpu_request_sched (cpu);
|
||||
*reschedule_cpu = cpu;
|
||||
|
||||
return PROC_NEED_RESCHEDULE;
|
||||
}
|
||||
|
||||
static void proc_irq_sched (void* arg, void* regs) {
|
||||
@@ -272,10 +283,12 @@ void proc_init (void) {
|
||||
#endif
|
||||
|
||||
struct proc* spin_proc = proc_spawn_rd ("spin.exe");
|
||||
proc_register (spin_proc, thiscpu);
|
||||
struct cpu* spin_cpu = thiscpu;
|
||||
proc_register (spin_proc, &spin_cpu);
|
||||
|
||||
struct proc* init = proc_spawn_rd ("init.exe");
|
||||
proc_register (init, NULL);
|
||||
struct cpu* init_cpu = thiscpu;
|
||||
proc_register (init, &init_cpu);
|
||||
|
||||
spin_lock_ctx_t ctxcpu;
|
||||
spin_lock (&spin_proc->cpu->lock, &ctxcpu);
|
||||
|
||||
Reference in New Issue
Block a user