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 <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Michal Privoznik 2017-06-07 13:38:14 +02:00
parent ba81c4ee4f
commit 055c7c48f7

View File

@ -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]);