On Wed, Oct 07, 2026 at 02:29:41PM -0400, Peter Xu wrote: > One thing I can think of that we need host-nodes= is when different > backends may be bound to different numa node, but since the current use > case already enabled memcg and looks like it can shift to completely > different numa nodes, it doesn't seem to be the case.
That is how these VMs start: libvirt turns the guest NUMA topology it gets from OpenStack into one backend per guest node, each with its own host-nodes. The cpuset is moved later, and not by libvirt, which refuses to change the nodeset of a running domain in strict mode. I agree that host-nodes plus a moving cpuset is not a setup to recommend, but it is what the stack gives us. > So it looks like a real issue and also looks severe, but it's a matter of > whether it should be fixed in qemu. If we want to fix it in QEMU, we > should have some solid reasoning. QEMU never asks the kernel for a static binding. It calls mbind() with MPOL_MF_STRICT | MPOL_MF_MOVE and without MPOL_F_STATIC_NODES. Without that flag the kernel contract is that the nodemask follows the cpuset: when cpuset.mems changes, the policy is rebound to the new nodes (Documentation/admin-guide/mm/numa_memory_policy.rst, the MPOL_F_STATIC_NODES section), and on cgroup v2 the pages are migrated with it (cgroup-v2.rst, cpuset.mems). By the time of the update the running QEMU had its policy rebound and its pages on the new nodes, and the guest ran fine. The incoming CPR QEMU is the only one that objects. It takes the nodemask from the command line and re-applies it to memory it did not allocate and the kernel has already moved. host-nodes no longer intersects cpuset.mems, so mbind() fails with EINVAL before it looks at a single page, and QEMU exits. The EINVAL itself is documented kernel behaviour. What QEMU adds on top is a lost guest. A normal migration destination never sees this: it is a fresh process which the management layer places before it starts. With CPR the new process inherits memory that has a history. Steve fixed the same class of problem for ROM contents (b42f28111e), pflash (e56ba1878f), PCI and vfio-pci reset (24c156dcd9, 031fbb7110) and IOMMU mappings (6ff4cccd13): realize must not redo what the old process already did to state that CPR preserved. 2b7e9739fa made the backends inherit their fd, but the mbind() and prealloc tail of host_memory_backend_memory_complete() still treats the memory as new. Prealloc, when enabled, is the same story. It runs MADV_POPULATE_WRITE over the whole inherited guest RAM while the guest is stopped. That is downtime growing with the RAM size, spent on pages that already exist. Maciej is right about extra backends. A backend the old QEMU did not have gets a fresh fd because cpr_find_fd() finds nothing for it, yet cpr_is_incoming() is true, so v1 would skip its binding too. v2 decides per backend, by whether its fd was inherited. For an inherited backend it still calls mbind(), reports a failure with warn_report() naming the backend, as Maciej suggested, and skips prealloc. Continuing after a failed mbind() is safe: at fault time the kernel ignores a bind policy with no node in the cpuset and allocates from the cpuset. Backends created fresh in the new process keep today's behaviour. Peter, would that work for you? I would rather agree on the direction before sending v2. Den
