From 629282d8845407c1aff9a26f5dc026e15121f8cd Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Fri, 1 Apr 2022 14:30:05 +0200 Subject: [PATCH] lib: Set up cpuset controller for restrictive numatune MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The aim of 'restrictive' numatune mode is to rely solely on CGroups to have QEMU running on configured NUMA nodes. However, we were never setting the cpuset controller when a domain was starting up. We are doing so only when virDomainSetNumaParameters() is called (aka live pinning). This is obviously wrong. Fortunately, fix is simple as 'restrictive' is similar to 'strict' - every location where VIR_DOMAIN_NUMATUNE_MEM_STRICT occurs can be audited and VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE case can be added. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2070380 Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/ch/ch_process.c | 3 ++- src/lxc/lxc_controller.c | 3 ++- src/qemu/qemu_process.c | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 785e4f8769..977082d585 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -254,7 +254,8 @@ virCHProcessSetupPid(virDomainObj *vm, virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 && - mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT && + (mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT || + mem_mode == VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) && virDomainNumatuneMaybeFormatNodeset(vm->def->numa, priv->autoNodeset, &mem_mask, -1) < 0) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 677fa5a4fb..d936f34793 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -811,7 +811,8 @@ static int virLXCControllerSetupResourceLimits(virLXCController *ctrl) virDomainNumatuneMemMode mode; if (virDomainNumatuneGetMode(ctrl->def->numa, -1, &mode) == 0) { - if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT && + if ((mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT || + mode == VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) && virCgroupControllerAvailable(VIR_CGROUP_CONTROLLER_CPUSET)) { /* Use virNuma* API iff necessary. Once set and child is exec()-ed, * there's no way for us to change it. Rely on cgroups (if available diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 07f1045490..995737ce86 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2646,7 +2646,8 @@ qemuProcessSetupPid(virDomainObj *vm, virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 && - mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT && + (mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT || + mem_mode == VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) && virDomainNumatuneMaybeFormatNodeset(vm->def->numa, priv->autoNodeset, &mem_mask, -1) < 0) @@ -3162,7 +3163,8 @@ static int qemuProcessHook(void *data) goto cleanup; if (virDomainNumatuneGetMode(h->vm->def->numa, -1, &mode) == 0) { - if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT && + if ((mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT || + mode == VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) && h->cfg->cgroupControllers & (1 << VIR_CGROUP_CONTROLLER_CPUSET) && virCgroupControllerAvailable(VIR_CGROUP_CONTROLLER_CPUSET)) { /* Use virNuma* API iff necessary. Once set and child is exec()-ed,