From 055c7c48f715f984e1070a5a9a9db3e7a7e271bc Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Wed, 7 Jun 2017 13:38:14 +0200 Subject: [PATCH] qemuProcessBuildDestroyHugepagesPath: create path more frequently https://bugzilla.redhat.com/show_bug.cgi?id=1455819 Currently, the per-domain path for huge pages mmap() for qemu is created iff domain has memoryBacking and hugepages in it configured. However, this alone is not enough because there can be a DIMM module with hugepages configured too. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- src/qemu/qemu_process.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4a66f0d5d6..59cca2736d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3283,6 +3283,31 @@ qemuProcessReconnectCheckMemAliasOrderMismatch(virDomainObjPtr vm) } +static bool +qemuProcessNeedHugepagesPath(virDomainDefPtr def) +{ + const long system_pagesize = virGetSystemPageSizeKB(); + size_t i; + + if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) + return true; + + for (i = 0; i < def->mem.nhugepages; i++) { + if (def->mem.hugepages[i].size != system_pagesize) + return true; + } + + for (i = 0; i < def->nmems; i++) { + if (def->mems[i]->model == VIR_DOMAIN_MEMORY_MODEL_DIMM && + def->mems[i]->pagesize && + def->mems[i]->pagesize != system_pagesize) + return true; + } + + return false; +} + + static int qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3291,9 +3316,13 @@ qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); char *hugepagePath = NULL; size_t i; + bool shouldBuild = false; int ret = -1; - if (vm->def->mem.nhugepages) { + if (build) + shouldBuild = qemuProcessNeedHugepagesPath(vm->def); + + if (!build || shouldBuild) { for (i = 0; i < cfg->nhugetlbfs; i++) { VIR_FREE(hugepagePath); hugepagePath = qemuGetDomainHugepagePath(vm->def, &cfg->hugetlbfs[i]);