61,6 → 61,7 |
#include <cpu.h> |
#include <print.h> |
#include <debug.h> |
#include <arch/smp/sun4v/smp.h> |
|
static void before_task_runs(void); |
static void before_thread_runs(void); |
220,6 → 221,8 |
|
atomic_dec(&CPU->nrdy); |
atomic_dec(&nrdy); |
if (CPU->arch.exec_unit) |
atomic_dec(&(CPU->arch.exec_unit->nrdy)); |
r->n--; |
|
/* |
565,6 → 568,31 |
average = atomic_get(&nrdy) / config.cpu_active + 1; |
count = average - atomic_get(&CPU->nrdy); |
|
/* calculate number of threads to be stolen from other exec. units */ |
spinlock_lock(&(CPU->arch.exec_unit->proposed_nrdy_lock)); |
bool eu_busy = calculate_optimal_nrdy(CPU->arch.exec_unit); |
unsigned int count_other_eus = CPU->arch.proposed_nrdy |
- atomic_get(&(CPU->nrdy)); |
spinlock_unlock(&(CPU->arch.exec_unit->proposed_nrdy_lock)); |
|
/* |
* If the CPU's parent core is overloaded, do not do the load |
* balancing, otherwise we would migrate threads which should be |
* migrated to other cores and since a thread cannot be migrated |
* multiple times, it would not be migrated to the other core |
* in the future. |
*/ |
if (eu_busy) |
return; |
|
/* |
* get the maximum - stole enough threads to satisfy both the need to |
* have all virtual CPUs equally busy and the need to have all the |
* cores equally busy |
*/ |
if (((int) count_other_eus) > count) |
count = count_other_eus; |
|
if (count <= 0) |
goto satisfied; |
|
622,6 → 650,8 |
|
atomic_dec(&cpu->nrdy); |
atomic_dec(&nrdy); |
if (cpu->arch.exec_unit) |
atomic_dec(&(cpu->arch.exec_unit->nrdy)); |
|
r->n--; |
list_remove(&t->rq_link); |