Greg Padgett has uploaded a new change for review. Change subject: WIP core: VdsSelector changes for CPU Overcommit (3/5) ......................................................................
WIP core: VdsSelector changes for CPU Overcommit (3/5) This patch series adds support for CPU Overcommitment based on counting host threads as cores for the purpose of VM startup/shutdown/migration. Patch 3: update host selection algorithm to take advantage of cpu overcommitment. VdsSelector now uses an "effective" core count. This is a direct plug-in replacement for using the physical CPU count, and is only in effect when vdsm on the host is not set to report threads as cores, the host CPU has HT enabled, and CPU overcommitment is enabled on the cluster. Change-Id: I7171f066d646378664e5832ba00fa9f436509b97 Signed-off-by: Greg Padgett <gpadg...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/EvenlyDistributeComparer.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsCpuVdsLoadBalancingAlgorithm.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCountVdsLoadBalancingAlgorithm.java 5 files changed, 23 insertions(+), 11 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/68/10168/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/EvenlyDistributeComparer.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/EvenlyDistributeComparer.java index 02f398c..8c475e6 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/EvenlyDistributeComparer.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/EvenlyDistributeComparer.java @@ -9,7 +9,7 @@ int vcpu = Config.<Integer> GetValue(ConfigValues.VcpuConsumptionPercentage); int spmCpu = (vds.getspm_status() == VdsSpmStatus.None) ? 0 : Config .<Integer> GetValue(ConfigValues.SpmVCpuConsumption); - int hostCores = vds.getcpu_cores(); + int hostCores = VdsSelector.geteffective_cpu_cores(vds); double hostCpu = vds.getusage_cpu_percent(); double pendingVcpus = vds.getpending_vcpus_count(); @@ -18,8 +18,11 @@ @Override public boolean IsBetter(VDS x, VDS y, VM vm) { - if (x.getcpu_cores() == null || y.getcpu_cores() == null || x.getusage_cpu_percent() == null - || y.getusage_cpu_percent() == null || x.getpending_vcpus_count() == null + if (VdsSelector.geteffective_cpu_cores(x) == null + || VdsSelector.geteffective_cpu_cores(y) == null + || x.getusage_cpu_percent() == null + || y.getusage_cpu_percent() == null + || x.getpending_vcpus_count() == null || y.getpending_vcpus_count() == null) { return false; } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java index d43a337..f7ddeb4 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java @@ -105,7 +105,7 @@ // The predicted CPU is actually the CPU that the VM will take considering how many cores it has and now many // cores the host has. This is why we take both parameters into consideration. - int predictedVmCpu = (vm.getUsageCpuPercent() * vm.getNumOfCpus()) / vds.getcpu_cores(); + int predictedVmCpu = (vm.getUsageCpuPercent() * vm.getNumOfCpus()) / VdsSelector.geteffective_cpu_cores(vds); boolean result = vds.getusage_cpu_percent() + predictedVmCpu <= vds.gethigh_utilization(); if (log.isDebugEnabled()) { log.debugFormat("Host {0} has {1}% CPU load; VM {2} is predicted to have {3}% CPU load; " + diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsCpuVdsLoadBalancingAlgorithm.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsCpuVdsLoadBalancingAlgorithm.java index 1fb5c65..0b6f3b7 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsCpuVdsLoadBalancingAlgorithm.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsCpuVdsLoadBalancingAlgorithm.java @@ -172,7 +172,7 @@ } private int calculateCpuUsage(VDS o1) { - return o1.getusage_cpu_percent() * o1.getcpu_cores() / o1.getvds_strength(); + return o1.getusage_cpu_percent() * VdsSelector.geteffective_cpu_cores(o1) / o1.getvds_strength(); } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java index 086fc3d..ac60fdf 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java @@ -11,6 +11,7 @@ import org.ovirt.engine.core.common.businessentities.MigrationSupport; import org.ovirt.engine.core.common.businessentities.Network; import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.businessentities.VDSType; import org.ovirt.engine.core.common.businessentities.VM; @@ -228,6 +229,13 @@ VdcBllMessages validate(VDS vds, StringBuilder sb, boolean isMigrate); } + public static Integer geteffective_cpu_cores(VDS vds) { + VDSGroup vdsGroup = DbFacade.getInstance().getVdsGroupDao().get(vds.getvds_group_id()); + return ((vdsGroup != null && vds.getcpu_cores() != null && vds.getvdsm_count_threads_as_cores() != null + && vdsGroup.getcount_threads_as_cores() && vds.getcpu_ht_enabled()) + ? vds.getcpu_cores() * 2 : vds.getcpu_cores()); + } + @SuppressWarnings("serial") final List<HostValidator> hostValidators = Collections.unmodifiableList(new ArrayList<HostValidator>(){ { @@ -283,8 +291,9 @@ add(new HostValidator() { @Override public VdcBllMessages validate(VDS vds, StringBuilder sb, boolean isMigrate) { - if (vds.getcpu_cores() != null && getVm().getNumOfCpus() > vds.getcpu_cores()) { - sb.append("has less cores(").append(vds.getcpu_cores()).append(") than ").append(getVm().getNumOfCpus()); + Integer cores = geteffective_cpu_cores(vds); + if (cores != null && getVm().getNumOfCpus() > cores) { + sb.append("has less cores(").append(cores).append(") than ").append(getVm().getNumOfCpus()); return VdcBllMessages.ACTION_TYPE_FAILED_VDS_VM_CPUS; } return null; diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCountVdsLoadBalancingAlgorithm.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCountVdsLoadBalancingAlgorithm.java index 45a6722..981fbe5 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCountVdsLoadBalancingAlgorithm.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCountVdsLoadBalancingAlgorithm.java @@ -40,7 +40,7 @@ List<VDS> vdses = LinqUtils.filter(getAllRelevantVdss(), new Predicate<VDS>() { @Override public boolean eval(VDS p) { - return p.getvm_count() > vmCountTemp * p.getcpu_cores(); + return p.getvm_count() > vmCountTemp * VdsSelector.geteffective_cpu_cores(p); } }); Collections.sort(vdses, new Comparator<VDS>() { @@ -86,7 +86,7 @@ List<VDS> vdses = LinqUtils.filter(getAllRelevantVdss(), new Predicate<VDS>() { @Override public boolean eval(VDS p) { - return p.getvm_count() < vmCountTemp * p.getcpu_cores(); + return p.getvm_count() < vmCountTemp * VdsSelector.geteffective_cpu_cores(p); } }); Collections.sort(vdses, new Comparator<VDS>() { @@ -132,8 +132,8 @@ List<VDS> vdses = LinqUtils.filter(getAllRelevantVdss(), new Predicate<VDS>() { @Override public boolean eval(VDS p) { - return p.getvm_count() < highVdsCountTemp * p.getcpu_cores() - && p.getvm_count() >= lowVdsCountTemp * p.getcpu_cores(); + return p.getvm_count() < highVdsCountTemp * VdsSelector.geteffective_cpu_cores(p) + && p.getvm_count() >= lowVdsCountTemp * VdsSelector.geteffective_cpu_cores(p); } }); setReadyToMigrationServers(LinqUtils.toMap(vdses, new DefaultMapper<VDS, Guid>() { -- To view, visit http://gerrit.ovirt.org/10168 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7171f066d646378664e5832ba00fa9f436509b97 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Greg Padgett <gpadg...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches