Alpha162 opened a new issue, #14868:
URL: https://github.com/apache/cloudstack/issues/14868
### The required feature described as a wish
As an operator, I'd like to offer KVM instances that are NUMA-aligned: the
guest sees NUMA nodes
that match the host's, each guest node's vCPUs run only on that host node's
cores, and its
memory stays on the same host node. I'd like to control it from a compute
offering, and have
CloudStack place these instances only on hosts where they fit.
### Why
Databases, latency-sensitive applications and large JVMs care about memory
locality. Today a
16-vCPU guest on a two-socket host shows 4 sockets of 4 cores and a single
NUMA node, and its
vCPUs and memory move freely across both host nodes. Users have asked for
this before: on users@
in 2014 and 2020, in discussion #9801 (CPU pinning) and in discussion #11187
and issue #11120
(hugepages per NUMA node). The answers so far have pointed at agent hooks,
libvirt hooks or
extraconfig, which on service offerings only allows the DPDK keys.
We've run guest NUMA nodes, pinning and strict memory binding on 4.22
through the KVM agent's
XML hook, so libvirt handles it fine. The management server doesn't know
about any of it though,
so placement, migration and scaling can undo it.
### What CloudStack does today (main)
- The KVM agent picks 6 or 4 cores per socket unless `cpu.corespersocket` is
set, without
looking at the host (`setCpuTopology`).
- There's no `vcpupin`, `emulatorpin`, `numatune` or `memoryBacking` support
in the KVM plugin.
- A dynamically scalable instance gets a synthetic single-cell `<cpu><numa>`
from
`GuestResourceDef`, in a second `<cpu>` element next to `CpuModeDef`'s.
`LibvirtVMDef` keeps
its components in a HashMap keyed by class name. We checked on libvirt
11.10: libvirt takes
mode, model and topology from the first `<cpu>` and merges cells from all
of them. Today
`CpuModeDef` happens to come out first, so the result is correct, but if
that order changed,
these instances would lose their CPU mode and topology.
- The agent folds NUMA nodes into the reported socket count and doesn't
report per-node CPUs or
memory. Placement only checks whole-host totals.
- Live migration leaves CPU pinning and NUMA tuning in the domain XML alone,
so any pinning goes
to the destination unchanged.
### Proposal
**Phase 1: the instance.**
- Compute offering details:
- `numa.policy`: `none` (default), `preferred` or `strict`.
- `numa.nodes`: `auto` (default) or a number.
- `numa.pin`: `node` (default) or `none`.
- They're merged into the VM spec in
`HypervisorGuruBase.toVirtualMachineTO`. A matching VM
detail can override them, for root admins only. Tenants can't set these.
- On the agent, following the `kvm.hint.dedicated` pattern (#14254):
- `CpuModeDef` writes the guest cells and a topology of one socket per
guest node.
- `GuestResourceDef` stops writing its own `<cpu>`. The dynamic-scaling
cell moves into
`CpuModeDef`'s, so every instance has a single `<cpu>` element.
- `CpuTuneDef` adds `vcpupin` (to the node's CPU set, minus isolated or
reserved cores).
- A new `NumaTuneDef` writes `numatune` with a `memnode` per cell.
- vCPUs and memory have to split evenly across the guest nodes, or
deployment fails with a clear
error. The agent doesn't quietly fall back.
- Hosts report their NUMA layout as host details: node count, CPUs and
memory per node, and
isolated CPUs.
- A basic per-node fit check in
`FirstFitAllocator.checkHostsCompatibilities`, so a strict
instance is never sent to a host where it can't start.
**Phase 2: movement.**
- The same fit check in `checkVmMigrationDestination`.
- The agent rewrites the pinning for the destination host during live
migration, the way
`updateVmSharesIfNeeded` does for shares.
- DRS skips NUMA-aware instances at first, and later gets per-node awareness.
**Phase 3 (optional): hugepages.** Per-node hugepage backing, and memory
capacity that stops
counting hugepage memory as free ordinary memory (#11187).
### Things to settle
- Live scaling: refuse it for NUMA-aware instances in phase 1, or support it
within fixed cells?
(The KVM scale command doesn't carry VM details today, and hot-added DIMMs
always go to node 0.)
- Ballooning: when it's on, `<memory>` is the instance's minimum RAM, and
the cells have to add
up to it. It's probably simplest to turn ballooning off for these
instances.
- Is `preferred` worth having, or only `strict`?
- Pinning with CPU overcommit above 1: document it, or refuse it?
### Compatibility
Off by default. Offerings without `numa.policy` behave exactly as they do
now. Phase 1 needs no
schema change. An old agent ignores the new details, and the management
server only places
NUMA-aware instances on hosts that report a layout.
### Target branch
CONTRIBUTING says features go to main, but 4.22.2 took a couple (#13877,
#14254). Many
operators will stay on 4.22 for some time, so I'd like phase 1 to be small
enough to consider
for 4.22.3. I'll go with what the release managers and the community prefer.
I'm planning to implement this and would welcome feedback on the design
first, especially on
live scaling and the setting names.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]