diff -Nru libvirt-6.6.0/debian/changelog libvirt-6.6.0/debian/changelog --- libvirt-6.6.0/debian/changelog 2021-02-09 16:14:26.000000000 +0100 +++ libvirt-6.6.0/debian/changelog 2021-02-22 11:07:55.000000000 +0100 @@ -1,3 +1,10 @@ +libvirt (6.6.0-1ubuntu3.4) groovy; urgency=medium + + * d/p/lp1915811-*: Fix NUMA topology population for machines with high number + of CPUs (LP: #1915811) + + -- Victor Manuel Tapia King Mon, 22 Feb 2021 12:23:53 +0100 + libvirt (6.6.0-1ubuntu3.3) groovy; urgency=medium * d/p/u/lp-1913266-qemu-Add-virtio-related-options-to-vsock.patch: allow diff -Nru libvirt-6.6.0/debian/patches/series libvirt-6.6.0/debian/patches/series --- libvirt-6.6.0/debian/patches/series 2021-02-09 16:14:26.000000000 +0100 +++ libvirt-6.6.0/debian/patches/series 2021-02-22 11:06:33.000000000 +0100 @@ -48,3 +48,5 @@ ubuntu/lp-1887490-cpu_map-Remove-monitor-feature-from-EPYC-Rome.patch ubuntu/lp-1901242-util-Fix-logic-in-virFileSetCOW.patch ubuntu/lp-1913266-qemu-Add-virtio-related-options-to-vsock.patch +ubuntu/lp1915811-01-virnuma-Don-t-work-around-numa_node_to_cpus.patch +ubuntu/lp1915811-02-virnuma-Use-numa_nodes_ptr-when-checking-av.patch diff -Nru libvirt-6.6.0/debian/patches/ubuntu/lp1915811-01-virnuma-Don-t-work-around-numa_node_to_cpus.patch libvirt-6.6.0/debian/patches/ubuntu/lp1915811-01-virnuma-Don-t-work-around-numa_node_to_cpus.patch --- libvirt-6.6.0/debian/patches/ubuntu/lp1915811-01-virnuma-Don-t-work-around-numa_node_to_cpus.patch 1970-01-01 01:00:00.000000000 +0100 +++ libvirt-6.6.0/debian/patches/ubuntu/lp1915811-01-virnuma-Don-t-work-around-numa_node_to_cpus.patch 2021-02-22 11:08:33.000000000 +0100 @@ -0,0 +1,71 @@ +From 24d7d85208f812a45686b32a0561cc9c5c9a49c9 Mon Sep 17 00:00:00 2001 +From: Michal Privoznik +Date: Fri, 21 Aug 2020 14:43:21 +0200 +Subject: [PATCH] virnuma: Don't work around numa_node_to_cpus() for + non-existent nodes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +In a very distant past, we came around machines that has not +continuous node IDs. This made us error out when constructing +capabilities XML. We resolved it by utilizing strange behaviour +of numa_node_to_cpus() in which it returned a mask with all bits +set for a non-existent node. However, this is not the only case +when it returns all ones mask - if the node exists and has enough +CPUs to fill the mask up (e.g. 128 CPUs). + +The fix consists of using nodemask_isset(&numa_all_nodes, ..) +prior to calling numa_node_to_cpus() to determine if the node +exists. + +Fixes: 628c93574758abb59e71160042524d321a33543f +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1860231 +Signed-off-by: Michal Privoznik +Reviewed-by: Daniel P. Berrangé + +Origin: upstream, https://libvirt.org/git/?p=libvirt.git;a=commit;h=24d7d85208 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1915811 +--- + src/util/virnuma.c | 18 +++++------------- + 1 file changed, 5 insertions(+), 13 deletions(-) + +--- a/src/util/virnuma.c ++++ b/src/util/virnuma.c +@@ -256,31 +256,23 @@ + int mask_n_bytes = max_n_cpus / 8; + size_t i; + g_autofree unsigned long *mask = NULL; +- g_autofree unsigned long *allonesmask = NULL; + g_autoptr(virBitmap) cpumap = NULL; + + *cpus = NULL; + +- if (VIR_ALLOC_N(mask, mask_n_bytes / sizeof(*mask)) < 0) +- return -1; ++ if (!nodemask_isset(&numa_all_nodes, node)) { ++ VIR_DEBUG("NUMA topology for cell %d is not available, ignoring", node); ++ return -2; ++ } + +- if (VIR_ALLOC_N(allonesmask, mask_n_bytes / sizeof(*mask)) < 0) ++ if (VIR_ALLOC_N(mask, mask_n_bytes / sizeof(*mask)) < 0) + return -1; + +- memset(allonesmask, 0xff, mask_n_bytes); +- +- /* The first time this returns -1, ENOENT if node doesn't exist... */ + if (numa_node_to_cpus(node, mask, mask_n_bytes) < 0) { + VIR_WARN("NUMA topology for cell %d is not available, ignoring", node); + return -2; + } + +- /* second, third... times it returns an all-1's mask */ +- if (memcmp(mask, allonesmask, mask_n_bytes) == 0) { +- VIR_DEBUG("NUMA topology for cell %d is invalid, ignoring", node); +- return -2; +- } +- + if (!(cpumap = virBitmapNew(max_n_cpus))) + return -1; + diff -Nru libvirt-6.6.0/debian/patches/ubuntu/lp1915811-02-virnuma-Use-numa_nodes_ptr-when-checking-av.patch libvirt-6.6.0/debian/patches/ubuntu/lp1915811-02-virnuma-Use-numa_nodes_ptr-when-checking-av.patch --- libvirt-6.6.0/debian/patches/ubuntu/lp1915811-02-virnuma-Use-numa_nodes_ptr-when-checking-av.patch 1970-01-01 01:00:00.000000000 +0100 +++ libvirt-6.6.0/debian/patches/ubuntu/lp1915811-02-virnuma-Use-numa_nodes_ptr-when-checking-av.patch 2021-02-22 11:08:38.000000000 +0100 @@ -0,0 +1,50 @@ +From 551fb778f5451d40211867365b5eb9b8384b4e3b Mon Sep 17 00:00:00 2001 +From: Michal Privoznik +Date: Fri, 11 Sep 2020 11:50:33 +0200 +Subject: [PATCH] virnuma: Use numa_nodes_ptr when checking available NUMA + nodes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +In v6.7.0-rc1~86 I've tried to fix a problem where we were not +detecting NUMA nodes properly because we misused behaviour of a +libnuma API and as it turned out the behaviour was correct for +hosts with 64 CPUs in one NUMA node. So I changed the code to use +nodemask_isset(&numa_all_nodes, ..) instead and it fixed the +problem on such hosts. However, what I did not realize is that +numa_all_nodes does not reflect all NUMA nodes visible to +userspace, it contains only those nodes that the process +(libvirtd) an allocate memory from, which can be only a subset of +all NUMA nodes. The bitmask that contains all NUMA nodes visible +to userspace and which one I should have used is: numa_nodes_ptr. +For curious ones: + +https://github.com/numactl/numactl/commit/4a22f2238234155e11e3e2717c011864722b767b + +And as I was fixing virNumaGetNodeCPUs() I came to realize that +we already have a function that wraps the correct bitmask: +virNumaNodeIsAvailable(). + +Fixes: 24d7d85208f812a45686b32a0561cc9c5c9a49c9 +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1876956 +Signed-off-by: Michal Privoznik +Reviewed-by: Daniel P. Berrangé + +Origin: upstream, https://libvirt.org/git/?p=libvirt.git;a=commit;h=551fb778f5 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1915811 +--- + src/util/virnuma.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/src/util/virnuma.c ++++ b/src/util/virnuma.c +@@ -260,7 +260,7 @@ + + *cpus = NULL; + +- if (!nodemask_isset(&numa_all_nodes, node)) { ++ if (!virNumaNodeIsAvailable(node)) { + VIR_DEBUG("NUMA topology for cell %d is not available, ignoring", node); + return -2; + }