diff --git a/src/scheduler/etc/sched.conf b/src/scheduler/etc/sched.conf index f8072681a9..b6f4fa4291 100644 --- a/src/scheduler/etc/sched.conf +++ b/src/scheduler/etc/sched.conf @@ -20,13 +20,13 @@ # # LIVE_RESCHEDS: Perform live (1) or cold migrations (0) when rescheduling a VM # -# CPU_THRESHOLD: Fraction of the actual amount of CPU -# (HOST/HOST_SHARE/MAX_CPU) that the scheduler will use. -# E.g. 0.9 means that only 90% of the total CPU will be used +# FREE_CPU_THRESHOLD: CPU usage that is neglected for computing the available +# CPU. Expressed as a fraction of the total CPU. +# E.g. 0.9 means that a free CPU load greater than 90% will +# result in a free CPU equal to the total CPU # -# MEM_THRESHOLD: Fraction of the actual amount of MEMORY -# (HOST/HOST_SHARE/MAX_MEM) that the scheduler will use. -# E.g. 0.9 means that only 90% of the total MEMORY will be used +# HYPERVISOR_MEM: Fraction of total MEMORY reserved for the hypervisor. +# E.g. 0.1 means that only 90% of the total MEMORY will be used # # DEFAULT_SCHED: Definition of the default scheduling algorithm # - policy: @@ -45,16 +45,14 @@ ONED_PORT = 2633 SCHED_INTERVAL = 30 -MAX_VM = 300 - +MAX_VM = 300 MAX_DISPATCH = 30 - -MAX_HOST = 1 +MAX_HOST = 1 LIVE_RESCHEDS = 0 -CPU_THRESHOLD = 0.9 -MEM_THRESHOLD = 1 +CPU_FREE_THRESHOLD = 0.9 +HYPERVISOR_MEM = 0.1 DEFAULT_SCHED = [ policy = 1 diff --git a/src/scheduler/include/Scheduler.h b/src/scheduler/include/Scheduler.h index e5df1af2bb..c531858628 100644 --- a/src/scheduler/include/Scheduler.h +++ b/src/scheduler/include/Scheduler.h @@ -54,8 +54,8 @@ protected: machines_limit(0), dispatch_limit(0), host_dispatch_limit(0), - cpu_threshold(0.9), - mem_threshold(1), + cpu_threshold(0), + mem_threshold(0), client(0) { am.addListener(this); diff --git a/src/scheduler/src/pool/HostXML.cc b/src/scheduler/src/pool/HostXML.cc index 874320da14..263d8747f4 100644 --- a/src/scheduler/src/pool/HostXML.cc +++ b/src/scheduler/src/pool/HostXML.cc @@ -23,18 +23,20 @@ void HostXML::get_capacity(int& cpu, int& memory, { vector result; - memory = free_mem; - cpu = free_cpu; + cpu = free_cpu; - /* eg. 96.7 >= 0.9 * 100, We need to round */ + /* eg. 96.7 >= 0.9 * 100, Round so 96.7 free is 100 (and CPU = 1, fits)*/ if ( cpu >= static_cast(cpu_threshold * static_cast(max_cpu)) ) { cpu = static_cast(ceil(static_cast(cpu)/100.0) * 100); } - if ( memory >= static_cast(mem_threshold * static_cast(max_mem)) ) + memory = free_mem - static_cast(mem_threshold * static_cast(max_mem)); + + /* sanity check in case the free_mem goes below the threshold */ + if ( memory < 0 ) { - memory = static_cast(ceil(static_cast(memory)/100.0) * 100); + memory = 0; } } diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index 77c77dd013..0174c69248 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -139,8 +139,9 @@ void Scheduler::start() conf.get("MAX_HOST", host_dispatch_limit); - conf.get("CPU_THRESHOLD", cpu_threshold); - conf.get("MEM_THRESHOLD", mem_threshold); + conf.get("CPU_FREE_THRESHOLD", cpu_threshold); + + conf.get("HYPERVISOR_MEM", mem_threshold); conf.get("LIVE_RESCHEDS", live_rescheds); @@ -441,8 +442,12 @@ void Scheduler::match() { ostringstream oss; - oss << "Host " << host->get_hid() << - " filtered out. It does not have enough capacity."; + oss << "Host " << host->get_hid() << " filtered out. " + << "Not enough capacity: " << endl + << "\t free cpu: " << host_cpu + << " vm cpu: " << vm_cpu << endl + << "\t free mem: " << host_memory + << " vm mem: " << vm_memory << endl; NebulaLog::log("SCHED",Log::DEBUG,oss); diff --git a/src/scheduler/src/sched/SchedulerTemplate.cc b/src/scheduler/src/sched/SchedulerTemplate.cc index c6aa61fc7d..ab9ec3f935 100644 --- a/src/scheduler/src/sched/SchedulerTemplate.cc +++ b/src/scheduler/src/sched/SchedulerTemplate.cc @@ -41,6 +41,8 @@ void SchedulerTemplate::set_conf_default() # MAX_HOST # DEFAULT_SCHED # LIVE_RESCHEDS +# CPU_FREE_THRESHOLD +# HYPERVISOR_MEM #------------------------------------------------------------------------------- */ // ONED_PORT @@ -85,6 +87,18 @@ void SchedulerTemplate::set_conf_default() vattribute = new VectorAttribute("DEFAULT_SCHED",vvalue); conf_default.insert(make_pair(attribute->name(),vattribute)); + + //CPU_FREE_THRESHOLD + value = "0.9"; + + attribute = new SingleAttribute("CPU_FREE_THRESHOLD",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + + //HYPERVISOR_MEM + value = "0.1"; + + attribute = new SingleAttribute("HYPERVISOR_MEM",value); + conf_default.insert(make_pair(attribute->name(),attribute)); } /* -------------------------------------------------------------------------- */