Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
how many functions will I inline in the VMs????
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 20 Nov 2016 18:42:50 +0000 (19:42 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 20 Nov 2016 18:42:50 +0000 (19:42 +0100)
src/simix/smx_vm.cpp

index 080cf30..515fb1f 100644 (file)
@@ -25,7 +25,7 @@ static long host_get_ramsize(sg_host_t vm, int *overcommit)
 }
 
 /* **** start a VM **** */
 }
 
 /* **** start a VM **** */
-static int __can_be_started(sg_host_t vm)
+void SIMIX_vm_start(sg_host_t vm)
 {
   sg_host_t pm = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getPm();
 
 {
   sg_host_t pm = static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getPm();
 
@@ -37,38 +37,21 @@ static int __can_be_started(sg_host_t vm)
   int pm_overcommit = pm->extension<simgrid::vm::VmHostExt>()->overcommit;
   long vm_ramsize = host_get_ramsize(vm, nullptr);
 
   int pm_overcommit = pm->extension<simgrid::vm::VmHostExt>()->overcommit;
   long vm_ramsize = host_get_ramsize(vm, nullptr);
 
-  if (!pm_ramsize) {
-    /* We assume users do not want to care about ramsize. */
-    return 1;
-  }
-
-  if (pm_overcommit) {
-    XBT_VERB("%s allows memory overcommit.", sg_host_get_name(pm));
-    return 1;
-  }
-
-  /* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */
-  long total_ramsize_of_vms = 0;
-  for (simgrid::surf::VirtualMachineImpl* ws_vm : simgrid::surf::VirtualMachineImpl::allVms_)
-    if (pm == ws_vm->getPm())
-      total_ramsize_of_vms += ws_vm->getRamsize();
-
-  if (vm_ramsize > pm_ramsize - total_ramsize_of_vms) {
-    XBT_WARN("cannnot start %s@%s due to memory shortage: vm_ramsize %ld, free %ld, pm_ramsize %ld (bytes).",
-        sg_host_get_name(vm), sg_host_get_name(pm),
-        vm_ramsize, pm_ramsize - total_ramsize_of_vms, pm_ramsize);
-    return 0;
+  if (pm_ramsize && !pm_overcommit) { /* Only verify that we don't overcommit on need */
+    /* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */
+    long total_ramsize_of_vms = 0;
+    for (simgrid::surf::VirtualMachineImpl* ws_vm : simgrid::surf::VirtualMachineImpl::allVms_)
+      if (pm == ws_vm->getPm())
+        total_ramsize_of_vms += ws_vm->getRamsize();
+
+    if (vm_ramsize > pm_ramsize - total_ramsize_of_vms) {
+      XBT_WARN("cannnot start %s@%s due to memory shortage: vm_ramsize %ld, free %ld, pm_ramsize %ld (bytes).",
+               sg_host_get_name(vm), sg_host_get_name(pm), vm_ramsize, pm_ramsize - total_ramsize_of_vms, pm_ramsize);
+      THROWF(vm_error, 0, "The VM %s cannot be started", vm->name().c_str());
+    }
   }
 
   }
 
-  return 1;
-}
-
-void SIMIX_vm_start(sg_host_t vm)
-{
-  if (__can_be_started(vm))
-    static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->setState(SURF_VM_STATE_RUNNING);
-  else
-    THROWF(vm_error, 0, "The VM %s cannot be started", vm->name().c_str());
+  static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->setState(SURF_VM_STATE_RUNNING);
 }
 
 /**
 }
 
 /**