fine tuning of our load balancer
This commit is contained in:
parent
b9a9c155b3
commit
d7dc5ec9b7
1 changed files with 17 additions and 14 deletions
|
@ -1090,12 +1090,11 @@ void update_load(void)
|
|||
{
|
||||
uint32_t core_id = CORE_ID;
|
||||
|
||||
if (runqueues[core_id].balance_counter > 0)
|
||||
runqueues[core_id].balance_counter--;
|
||||
|
||||
runqueues[core_id].balance_counter--;
|
||||
runqueues[core_id].load_counter--;
|
||||
if (runqueues[core_id].load_counter < 0) {
|
||||
runqueues[core_id].load_counter += TIMER_FREQ/5 + 1;
|
||||
|
||||
if (runqueues[core_id].load_counter <= 0) {
|
||||
runqueues[core_id].load_counter += TIMER_FREQ/5;
|
||||
|
||||
spinlock_irqsave_lock(&runqueues[core_id].lock);
|
||||
runqueues[core_id].load[0] *= EXP_1;
|
||||
|
@ -1154,14 +1153,14 @@ void load_balancing(void)
|
|||
|
||||
spinlock_irqsave_lock(&runqueues[i].lock);
|
||||
if ((runqueues[i].load[0] >> (FSHIFT-1)) > (runqueues[core_id].load[0] >> (FSHIFT-1))) {
|
||||
kprintf("Try to steal a task from core %u (load %u) to %u (load %u)\n", i, runqueues[i].load[0], core_id, runqueues[core_id].load[0]);
|
||||
kprintf("Task on core %u: %u, core %u, %u\n", i, runqueues[i].nr_tasks, core_id, runqueues[i].nr_tasks);
|
||||
//kprintf("Try to steal a task from core %u (load %u) to %u (load %u)\n", i, runqueues[i].load[0], core_id, runqueues[core_id].load[0]);
|
||||
//kprintf("Task on core %u: %u, core %u, %u\n", i, runqueues[i].nr_tasks, core_id, runqueues[i].nr_tasks);
|
||||
|
||||
prio = lsb(runqueues[i].prio_bitmap);
|
||||
if (prio < sizeof(size_t)*8) {
|
||||
// steal a ready task
|
||||
task = runqueues[i].queue[prio-1].last;
|
||||
kprintf("Try to steal a ready task %d with prio %u\n", task->id, prio);
|
||||
kprintf("Core %u steals the task %d form %u with prio %u\n", core_id, task->id, i, prio);
|
||||
|
||||
// remove last element from queue i
|
||||
if (task->prev)
|
||||
|
@ -1187,7 +1186,7 @@ void load_balancing(void)
|
|||
runqueues[core_id].nr_tasks++;
|
||||
runqueues[i].nr_tasks--;
|
||||
runqueues[core_id].balance_counter = TIMER_FREQ/2;
|
||||
} else {
|
||||
} /*else {
|
||||
task_t* tmp;
|
||||
|
||||
// steal a blocked task
|
||||
|
@ -1195,7 +1194,7 @@ void load_balancing(void)
|
|||
if (!task) // Ups, found no valid task to steal
|
||||
goto no_task_found;
|
||||
|
||||
kprintf("Try to steal blocked task %d\n", task->id);
|
||||
kprintf("Core %u steals the blocked task %d from %u with prio %u\n", core_id, task->id, i, task->prio);
|
||||
|
||||
// remove first timer from queue i
|
||||
if (runqueues[i].timers.first == runqueues[i].timers.last)
|
||||
|
@ -1230,14 +1229,16 @@ void load_balancing(void)
|
|||
task->last_core = CORE_ID;
|
||||
|
||||
// update task counters
|
||||
runqueues[core_id].nr_tasks++;
|
||||
runqueues[i].nr_tasks--;
|
||||
runqueues[core_id].balance_counter = TIMER_FREQ/2;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
no_task_found:
|
||||
//no_task_found:
|
||||
spinlock_irqsave_unlock(&runqueues[i].lock);
|
||||
}
|
||||
|
||||
if (runqueues[core_id].balance_counter <= 0)
|
||||
runqueues[core_id].balance_counter = TIMER_FREQ/2;
|
||||
|
||||
spinlock_irqsave_unlock(&runqueues[core_id].lock);
|
||||
#endif
|
||||
}
|
||||
|
@ -1306,6 +1307,8 @@ void scheduler(void)
|
|||
prio = msb(runqueues[core_id].prio_bitmap); // determines highest priority
|
||||
#if MAX_CORES > 1
|
||||
if (prio >= sizeof(size_t)*8) {
|
||||
// push load balancing
|
||||
runqueues[core_id].balance_counter -= TIMER_FREQ/20;
|
||||
load_balancing();
|
||||
prio = msb(runqueues[core_id].prio_bitmap); // retry...
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue