support for dynamically toggling time sharing when CPU is oversubscribed

This commit is contained in:
Balazs Gerofi
2015-08-07 08:51:50 +09:00
parent aa191b87d3
commit 0a0e2c04a0
3 changed files with 46 additions and 0 deletions

View File

@ -57,6 +57,8 @@ extern void restore_fp_regs(struct process *proc);
void settid(struct process *proc, int mode, int newcpuid, int oldcpuid);
extern void __runq_add_proc(struct process *proc, int cpu_id);
extern void terminate_host(int pid);
extern void lapic_timer_enable(unsigned int clocks);
extern void lapic_timer_disable();
int refcount_fork_tree_node(struct fork_tree_node *ftn)
{
@ -2264,6 +2266,23 @@ redo:
list_add_tail(&prev->sched_list, &(v->runq));
++v->runq_len;
}
/* Toggle timesharing if CPU core is oversubscribed
* (on last CPU core only for now) */
if (ihk_mc_get_processor_id() == num_processors - 1) {
if (v->runq_len > 1) {
if (!cpu_local_var(timer_enabled)) {
lapic_timer_enable(10000000);
cpu_local_var(timer_enabled) = 1;
}
}
else {
if (cpu_local_var(timer_enabled)) {
lapic_timer_disable();
cpu_local_var(timer_enabled) = 0;
}
}
}
}
if (v->flags & CPU_FLAG_NEED_MIGRATE) {