set_timer: Start timer when runnable thread count is bigger than one
Change-Id: Ie32799fff2936ffc057f166db5681edccdbf5920
This commit is contained in:
@@ -3063,13 +3063,26 @@ ack:
|
||||
ihk_mc_spinlock_unlock(&cur_v->migq_lock, irqstate);
|
||||
}
|
||||
|
||||
void
|
||||
set_timer()
|
||||
void set_timer(int runq_locked)
|
||||
{
|
||||
struct cpu_local_var *v = get_this_cpu_local_var();
|
||||
struct thread *thread;
|
||||
int num_running = 0;
|
||||
unsigned long irqstate;
|
||||
|
||||
if (!runq_locked) {
|
||||
irqstate = ihk_mc_spinlock_lock(&(v->runq_lock));
|
||||
}
|
||||
|
||||
list_for_each_entry(thread, &v->runq, sched_list) {
|
||||
if (thread->status != PS_RUNNING) {
|
||||
continue;
|
||||
}
|
||||
num_running++;
|
||||
}
|
||||
|
||||
/* Toggle timesharing if CPU core is oversubscribed */
|
||||
if (v->runq_len > 1 || v->current->itimer_enabled) {
|
||||
if (num_running > 1 || v->current->itimer_enabled) {
|
||||
if (!cpu_local_var(timer_enabled)) {
|
||||
lapic_timer_enable(/*10000000*/1000000);
|
||||
cpu_local_var(timer_enabled) = 1;
|
||||
@@ -3081,6 +3094,10 @@ set_timer()
|
||||
cpu_local_var(timer_enabled) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!runq_locked) {
|
||||
ihk_mc_spinlock_unlock(&(v->runq_lock), irqstate);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3222,7 +3239,7 @@ void schedule(void)
|
||||
reset_cputime();
|
||||
}
|
||||
|
||||
set_timer();
|
||||
set_timer(1);
|
||||
|
||||
if (switch_ctx) {
|
||||
dkprintf("schedule: %d => %d \n",
|
||||
|
||||
Reference in New Issue
Block a user