Repository navigation
Conversation
…ding) A compute offering can make its KVM instances NUMA-aware with three details: numa.policy (none, preferred or strict), numa.nodes (auto or a number) and numa.pin (node or none). For such an instance the KVM agent splits the vCPUs and memory evenly over guest NUMA cells, picks a host NUMA node for each cell, pins the cell's vCPUs to that node's CPUs and binds its memory to the node. The instance gets one socket per guest node. It fails to start with a clear error when it does not fit, and never falls back quietly. The agent reports the number of usable CPUs and the memory of each host NUMA node as host details, and FirstFitAllocator only keeps KVM hosts whose NUMA nodes are large enough. The guest NUMA cells are written by CpuModeDef. GuestResourceDef no longer writes a second <cpu> element for instances whose memory can be hot-added, so the domain XML has a single <cpu> element. A NUMA-aware instance gets all of its vCPUs and memory at start, so the offering cannot have dynamic scaling enabled. The existing checks then refuse to scale such an instance while it runs. Refs apache#14868 Generated-by: Claude Code (claude-mythos-5-2)
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds phase 1 of #14868: a compute offering can make its KVM instances NUMA-aware.
Three compute offering details control it:
numa.policynone(default),preferred,strictnuma.nodesauto(default) or a numberautouses the fewest host nodes the instance fits innuma.pinnode(default),noneWhat happens for a NUMA-aware instance:
CpuModeDefwrites the cells and a topology of one socket per guest node.CpuTuneDefwrites avcpupinper vCPU, to the host node's CPUs without the kernel-isolated ones. A newNumaTuneDefwritesnumatunewith amemnodeper cell.host.numa.nodes,host.numa.node.<id>).FirstFitAllocatorskips KVM hosts that haven't reported a layout or whose nodes are too small.One change affects instances that aren't NUMA-aware. Today a dynamically scalable instance gets two
<cpu>elements: one fromCpuModeDefand one fromGuestResourceDefholding the cell that memory hot-add needs. libvirt takes the mode, model and topology from the first one, andLibvirtVMDefkeeps its components in aHashMap, so the result depends on iteration order. That cell now goes intoCpuModeDef's element and the domain XML has a single<cpu>. With a DPDK NUMA extra config nothing changes.Narrower than the issue text, on purpose:
dynamicscalingenabled=false, so the existing checks refuse to scale such an instance while it runs. Hot-add within fixed cells can come later.strict, the agent checks the memory available on each node at start.Off by default. Offerings without
numa.policybehave as before, and there's no schema change.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
How Has This Been Tested?
Unit tests: 75 new ones in
utils, the KVM plugin andserver. The full suites of those three modules pass on this branch (8,059 tests).End to end on a build of this branch. A small lab upgraded from 4.23.0.0 to packages built from this branch (24.0.0-SNAPSHOT, Ubuntu 24.04, two KVM hosts with two NUMA nodes of four CPUs each):
host.numa.nodes=0,1andhost.numa.node.<id>=4;<memory>createServiceOfferingwithnuma.policy=strictand dynamic scaling left at its defaultcreateServiceOfferingwithnuma.policy=always,numa.nodes=0ornuma.pin=corestrict,auto, 2 vCPUsbindto that nodestrict,auto, 8 vCPUssockets='2', each cell pinned and bound to its own nodepreferred,numa.pin=noneprefer, novcpupinstrict, 5 vCPUs;strict, 1 node, 12 GiB;strict, 4 nodesnumatune<cpu>element holding the mode, the topology and the hot-add cell. Live scaling it from 512 MB to 1 GiB works and attaches the DIMM to node 0On hardware. On a KVM host (AlmaLinux 9, libvirt 11.10, two NUMA nodes with interleaved CPU numbering and CPUs 0-1 isolated), with the agent side of this change ported to 4.22.0.1:
strict, 2 nodes, 4 vCPUs, 2 GiBsockets='2', vCPUs 0-1 pinned to node 0's CPUs and 2-3 to node 1's./proc/<pid>/numa_mapsshows the guest RAM asbind:0andbind:1, with pages only on the bound nodestrict,auto, 4 vCPUsstrict,auto, 16 vCPUs (15 usable CPUs per node)preferred,numa.pin=noneprefer, novcpupinstrict, 2 nodes, 3 vCPUsstrict, 1 node, 16 vCPUsnuma.policy=sometimes<cpu>element, no pinningThe isolated CPUs were left out of every
vcpupin, and the kernel'sCpus_allowed_listof each vCPU thread matched.Running domain XML of the first case:
Not tested: HA restarts, host maintenance, DRS, and live migration between hosts with different NUMA layouts. Migration copies the pinning as it is, so it needs the destination to have the same CPU numbering until phase 2.
How did you try to break this feature and the system with this change?