Search in sources :

Example 11 with VdsNumaNode

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();
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) LinkedList(java.util.LinkedList)

Example 12 with VdsNumaNode

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);
        }
    }
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) NumaTuneMode(org.ovirt.engine.core.common.businessentities.NumaTuneMode) Map(java.util.Map) HashMap(java.util.HashMap)

Example 13 with VdsNumaNode

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;
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode)

Example 14 with VdsNumaNode

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;
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) NumaNodeStatistics(org.ovirt.engine.core.common.businessentities.NumaNodeStatistics) CpuStatistics(org.ovirt.engine.core.common.businessentities.CpuStatistics)

Example 15 with VdsNumaNode

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();
        });
    }
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) MenuBar(org.ovirt.engine.ui.common.widget.MenuBar)

Aggregations

VdsNumaNode (org.ovirt.engine.core.common.businessentities.VdsNumaNode)22 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)6 VmNumaNode (org.ovirt.engine.core.common.businessentities.VmNumaNode)6 Map (java.util.Map)3 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 Test (org.junit.Test)2 NumaNode (org.ovirt.engine.api.model.NumaNode)2 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)2 CpuStatistics (org.ovirt.engine.core.common.businessentities.CpuStatistics)2 NumaNodeStatistics (org.ovirt.engine.core.common.businessentities.NumaNodeStatistics)2 Guid (org.ovirt.engine.core.compat.Guid)2 HTML (com.google.gwt.user.client.ui.HTML)1 DecimalFormat (java.text.DecimalFormat)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 Core (org.ovirt.engine.api.model.Core)1 Cores (org.ovirt.engine.api.model.Cores)1