-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: Change the CPUPolicyUnit for dedicated pinning
Before the introduction of the exclusively pinned CPUs, the logic of CPUPolicyUnit allowed to check the filtering constraints for each VM in the vm group individually. The constraint was that the number of VM's CPUs had to be >= host CPUs. With the introduction of the exclusively pinned CPUs, that is no more possible - if the group contained VMs with both, shared and exclusively pinned CPUs, we need to calculate the CPU count constraints for the whole group (similar to huge pages in HugePagesFilterPolicyUnit). Now the algorithm for calculating if the vm group fits into the host is as follows: 1. Calculate the host CPU count 2. Calculate the currently exclusively pinned CPUs (including pending) 3. Pin the vms that are being schedulled and count how many CPUs will be taken 4. Calculate how many shared CPUs are required to be left on the host as the maximum of required shared CPUs for vmGroup, pending VMs and running VMs. The host can fit the VMs if: hostCpuCount - exclusiveCpus - maxSharedCpuCount >= 0 Note that the calculation of the previous values may differ based on the cluster setting of "Count threads as cores".
- Loading branch information
1 parent
c59f909
commit bfc1395
Showing
12 changed files
with
297 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuTopologyPolicyUnit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.ovirt.engine.core.bll.scheduling.policyunits; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl; | ||
import org.ovirt.engine.core.bll.scheduling.SchedulingContext; | ||
import org.ovirt.engine.core.bll.scheduling.SchedulingUnit; | ||
import org.ovirt.engine.core.bll.scheduling.pending.PendingResourceManager; | ||
import org.ovirt.engine.core.common.businessentities.CpuPinningPolicy; | ||
import org.ovirt.engine.core.common.businessentities.VDS; | ||
import org.ovirt.engine.core.common.businessentities.VM; | ||
import org.ovirt.engine.core.common.errors.EngineMessage; | ||
import org.ovirt.engine.core.common.scheduling.PerHostMessages; | ||
import org.ovirt.engine.core.common.scheduling.PolicyUnit; | ||
import org.ovirt.engine.core.common.scheduling.PolicyUnitType; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@SchedulingUnit( | ||
guid = "35c2f1a5-8928-48e9-81ac-4c49eb49d60e", | ||
name = "CPUTopology", | ||
type = PolicyUnitType.FILTER, | ||
description = "Runs VMs only on hosts with a proper CPU topology") | ||
public class CpuTopologyPolicyUnit extends PolicyUnitImpl { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(CpuTopologyPolicyUnit.class); | ||
|
||
public CpuTopologyPolicyUnit(PolicyUnit policyUnit, PendingResourceManager pendingResourceManager) { | ||
super(policyUnit, pendingResourceManager); | ||
} | ||
|
||
@Override | ||
public List<VDS> filter(SchedulingContext context, List<VDS> hosts, VM vm, PerHostMessages messages) { | ||
List<VDS> candidates = new ArrayList<>(); | ||
|
||
for (VDS host : hosts) { | ||
|
||
if (host.getCpuSockets() == null || host.getCpuCores() == null || host.getCpuThreads() == null) { | ||
log.warn("Unknown number of cores for host {}.", host.getName()); | ||
continue; | ||
} | ||
|
||
// when the VM uses Resize and PIN CPU pinning policy the host needs to have | ||
// more than one core per socket | ||
if (vm.getCpuPinningPolicy() == CpuPinningPolicy.RESIZE_AND_PIN_NUMA) { | ||
int coresPerSocket = host.getCpuCores() / host.getCpuSockets(); | ||
|
||
if (coresPerSocket <= 1) { | ||
messages.addMessage(host.getId(), EngineMessage.VAR__DETAIL__NOT_ENOUGH_CORES_PER_SOCKET_FOR_RESIZE_AND_PIN.toString()); | ||
log.debug( | ||
"Host '{}' has only one core per socket. Resize and pin requires more than one core per socket", | ||
host.getName()); | ||
continue; | ||
} | ||
} else if (vm.getCpuPinningPolicy() == CpuPinningPolicy.DEDICATED) { | ||
// the dedicated pinning requires that all vThreads of the same vCore are pinned | ||
// to the same physical core. That is why the number of threads per core for the VM | ||
// cannot exceed the number of threads per core on the host | ||
int threadsPerCore = host.getCpuThreads() / host.getCpuCores(); | ||
|
||
if (threadsPerCore < vm.getThreadsPerCpu()) { | ||
messages.addMessage(host.getId(), EngineMessage.VAR__DETAIL__NOT_ENOUGH_THREADS_PER_CORE_FOR_DEDICATED.toString()); | ||
log.debug( | ||
"Host '{}' has not enough CPU threads per core to run the VM with Dedicated CPU pinning policy", | ||
host.getName()); | ||
continue; | ||
} | ||
} | ||
candidates.add(host); | ||
} | ||
return candidates; | ||
} | ||
} |
Oops, something went wrong.