From 77cb01bc0fec4d0da02e1d4df75d28870b0ef926 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 13 Sep 2016 15:55:06 +0200 Subject: [PATCH] numa: Rename virNumaGetHostNodeset and make it return only nodes with memory Name it virNumaGetHostMemoryNodeset and return only NUMA nodes which have memory installed. This is necessary as the kernel is not very happy to set the memory cgroup setting for nodes which do not have any memory. This would break vcpu hotplug with following message on such configruation: Invalid value '0,8' for 'cpuset.mems': Invalid argument Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1375268 --- src/libvirt_private.syms | 2 +- src/qemu/qemu_cgroup.c | 4 ++-- src/util/virnuma.c | 13 +++++++++++-- src/util/virnuma.h | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2569772ec2..80d5e86d0e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2059,7 +2059,7 @@ virNodeSuspendGetTargetMask; # util/virnuma.h virNumaGetAutoPlacementAdvice; virNumaGetDistances; -virNumaGetHostNodeset; +virNumaGetHostMemoryNodeset; virNumaGetMaxNode; virNumaGetNodeMemory; virNumaGetPageInfo; diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index fe94613b77..4bce601fac 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -860,7 +860,7 @@ qemuRestoreCgroupState(virDomainObjPtr vm) virBitmapPtr all_nodes; virCgroupPtr cgroup_temp = NULL; - if (!(all_nodes = virNumaGetHostNodeset())) + if (!(all_nodes = virNumaGetHostMemoryNodeset())) goto error; if (!(mem_mask = virBitmapFormat(all_nodes))) @@ -1166,7 +1166,7 @@ qemuCgroupEmulatorAllNodesAllow(virCgroupPtr cgroup, !virCgroupHasController(cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) return 0; - if (!(all_nodes = virNumaGetHostNodeset())) + if (!(all_nodes = virNumaGetHostMemoryNodeset())) goto cleanup; if (!(all_nodes_str = virBitmapFormat(all_nodes))) diff --git a/src/util/virnuma.c b/src/util/virnuma.c index c4d11fa6e0..bebe301f8d 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -987,10 +987,17 @@ virNumaNodesetIsAvailable(virBitmapPtr nodeset) return true; } + +/** + * virNumaGetHostMemoryNodeset: + * + * Returns a bitmap of guest numa node ids that contain memory. + */ virBitmapPtr -virNumaGetHostNodeset(void) +virNumaGetHostMemoryNodeset(void) { int maxnode = virNumaGetMaxNode(); + unsigned long long nodesize; size_t i = 0; virBitmapPtr nodeset = NULL; @@ -1004,7 +1011,9 @@ virNumaGetHostNodeset(void) if (!virNumaNodeIsAvailable(i)) continue; - ignore_value(virBitmapSetBit(nodeset, i)); + /* if we can't detect NUMA node size assume that it's present */ + if (virNumaGetNodeMemory(i, &nodesize, NULL) < 0 || nodesize > 0) + ignore_value(virBitmapSetBit(nodeset, i)); } return nodeset; diff --git a/src/util/virnuma.h b/src/util/virnuma.h index 1f3c0ad8a7..f3eef324a4 100644 --- a/src/util/virnuma.h +++ b/src/util/virnuma.h @@ -33,7 +33,7 @@ char *virNumaGetAutoPlacementAdvice(unsigned short vcups, int virNumaSetupMemoryPolicy(virDomainNumatuneMemMode mode, virBitmapPtr nodeset); -virBitmapPtr virNumaGetHostNodeset(void); +virBitmapPtr virNumaGetHostMemoryNodeset(void); bool virNumaNodesetIsAvailable(virBitmapPtr nodeset); bool virNumaIsAvailable(void); int virNumaGetMaxNode(void);