use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.
the class VmInfoBuildUtils method findCpusToPinIoAndEmulator.
private String findCpusToPinIoAndEmulator(VM vm, Map<String, Object> cpuPinning, MemoizingSupplier<List<VdsNumaNode>> hostNumaNodesSupplier, int vdsCpuThreads) {
List<VdsNumaNode> vdsNumaNodes = hostNumaNodesSupplier.get();
Set<Integer> vdsPinnedCpus = getAllPinnedPCpus(cpuPinning);
VdsNumaNode mostPinnedPnumaNode = vdsNumaNodes.isEmpty() ? null : vdsNumaNodes.get(0);
int maxNumOfPinnedCpusForNode = 0;
// IO threads and emulator threads to
for (VdsNumaNode pNode : vdsNumaNodes) {
if (pNode.getCpuIds().isEmpty()) {
continue;
}
int numOfPinnedCpus = CollectionUtils.intersection(pNode.getCpuIds(), vdsPinnedCpus).size();
if (maxNumOfPinnedCpusForNode < numOfPinnedCpus) {
maxNumOfPinnedCpusForNode = numOfPinnedCpus;
mostPinnedPnumaNode = pNode;
} else if (maxNumOfPinnedCpusForNode == numOfPinnedCpus && !mostPinnedPnumaNode.getCpuIds().isEmpty()) {
// choose the NUMA node with lower CPU ids
mostPinnedPnumaNode = getNumaNodeWithLowerCpuIds(mostPinnedPnumaNode, pNode);
}
}
// Prepare the list of one or two CPUs to pin Io and emulator threads to
List<Integer> retCpusList = new LinkedList<>();
if (mostPinnedPnumaNode == null || mostPinnedPnumaNode.getCpuIds().isEmpty()) {
// in case no NUMA node found or no CPU's for the NUMA node,
// set pinned CPU's to be {0,1} or just {0) (depends on the number of CPUs in host)
retCpusList.add(0);
if (vdsCpuThreads > 1) {
retCpusList.add(1);
}
} else {
retCpusList.add(mostPinnedPnumaNode.getCpuIds().get(0));
if (mostPinnedPnumaNode.getCpuIds().size() > 1) {
retCpusList.add(mostPinnedPnumaNode.getCpuIds().get(1));
}
}
String overridenPinCpus = getOverriddenPinnedCpusList(vdsPinnedCpus, retCpusList);
if (!overridenPinCpus.isEmpty()) {
log.warn("IO thread(s), Emulator thread(s) and few CPU thread(s) are pinned to the same physical CPU(s): [{}], for High Performance " + "VM {} {}. Please consider changing the CPU pinning topology to avoid that overlapping.", overridenPinCpus, vm.getName(), vm.getId());
}
return retCpusList.size() == 2 ? retCpusList.get(0) + "," + retCpusList.get(1) : retCpusList.get(0).toString();
}
use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.
the class VmInfoBuilderImpl method buildVmNumaProperties.
/**
* Numa will use the same compatibilityVersion as cpu pinning since numa may also add cpu pinning configuration and
* the two features have almost the same libvirt version support
*/
@Override
public void buildVmNumaProperties() {
List<VdsNumaNode> totalVdsNumaNodes = vmInfoBuildUtils.getVdsNumaNodes(vdsId);
if (totalVdsNumaNodes.isEmpty()) {
log.warn("No NUMA nodes found for host {} for vm {} {}", vdsId, vm.getName(), vm.getId());
return;
}
List<VmNumaNode> vmNumaNodes = vmInfoBuildUtils.getVmNumaNodes(vm);
if (vmNumaNodes.isEmpty()) {
return;
}
NumaTuneMode numaTune = vm.getNumaTuneMode();
if (numaTune != null) {
Map<String, Object> numaTuneSetting = NumaSettingFactory.buildVmNumatuneSetting(numaTune, vmNumaNodes);
if (!numaTuneSetting.isEmpty()) {
createInfo.put(VdsProperties.NUMA_TUNE, numaTuneSetting);
}
}
List<Map<String, Object>> createVmNumaNodes = NumaSettingFactory.buildVmNumaNodeSetting(vmNumaNodes);
if (!createVmNumaNodes.isEmpty()) {
createInfo.put(VdsProperties.VM_NUMA_NODES, createVmNumaNodes);
}
if (StringUtils.isEmpty(vm.getCpuPinning())) {
Map<String, Object> cpuPinDict = NumaSettingFactory.buildCpuPinningWithNumaSetting(vmNumaNodes, totalVdsNumaNodes);
if (!cpuPinDict.isEmpty()) {
createInfo.put(VdsProperties.cpuPinning, cpuPinDict);
}
}
}
use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.
the class MemoryPolicyUnit method canVmNumaPinnedToVds.
private boolean canVmNumaPinnedToVds(VM vm, List<VmNumaNode> nodes, VDS vds) {
List<VdsNumaNode> pNodes = vdsNumaNodeDao.getAllVdsNumaNodeByVdsId(vds.getId());
if (pNodes == null || pNodes.isEmpty()) {
return false;
}
Map<Integer, VdsNumaNode> indexMap = toMap(pNodes);
for (VmNumaNode vNode : nodes) {
for (Integer pinnedIndex : vNode.getVdsNumaNodeList()) {
if (vNode.getMemTotal() > indexMap.get(pinnedIndex).getNumaNodeStatistics().getMemFree()) {
return false;
}
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildVdsNumaNodeStatistics.
private static VdsNumaNode buildVdsNumaNodeStatistics(DecimalFormat percentageFormatter, Map.Entry<Integer, List<CpuStatistics>> item) {
VdsNumaNode node = new VdsNumaNode();
NumaNodeStatistics nodeStat = new NumaNodeStatistics();
double nodeCpuUser = 0.0;
double nodeCpuSys = 0.0;
double nodeCpuIdle = 0.0;
for (CpuStatistics cpuStat : item.getValue()) {
nodeCpuUser += cpuStat.getCpuUser();
nodeCpuSys += cpuStat.getCpuSys();
nodeCpuIdle += cpuStat.getCpuIdle();
}
nodeStat.setCpuUser(Double.parseDouble(percentageFormatter.format(nodeCpuUser / item.getValue().size())));
nodeStat.setCpuSys(Double.parseDouble(percentageFormatter.format(nodeCpuSys / item.getValue().size())));
nodeStat.setCpuIdle(Double.parseDouble(percentageFormatter.format(nodeCpuIdle / item.getValue().size())));
nodeStat.setCpuUsagePercent((int) (nodeStat.getCpuSys() + nodeStat.getCpuUser()));
node.setIndex(item.getKey());
node.setNumaNodeStatistics(nodeStat);
return node;
}
use of org.ovirt.engine.core.common.businessentities.VdsNumaNode in project ovirt-engine by oVirt.
the class DraggableVirtualNumaPanel method createMenu.
private void createMenu(final List<VdsNumaNode> numaNodeList, int indexToSkip) {
menuBar = new MenuBar(true);
for (final VdsNumaNode numaNode : numaNodeList) {
final int nodeIndex = numaNode.getIndex();
menuBar.addItem(messages.numaNode(nodeIndex), () -> {
UpdatedVnumaEvent.fire(DraggableVirtualNumaPanel.this, nodeModel.getVm().getId(), true, nodeModel.getIndex(), nodeIndex);
menuPopup.hide();
});
}
if (nodeModel.isPinned()) {
menuBar.addSeparator();
menuBar.addItem(constants.unPinNode(), () -> {
UpdatedVnumaEvent.fire(DraggableVirtualNumaPanel.this, nodeModel.getVm().getId(), false, nodeModel.getIndex(), -1);
menuPopup.hide();
});
}
}
Aggregations