|
|
9119d9 |
From cb1894016dbd5a776fcb86a7c0f00a898e7ba023 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <cb1894016dbd5a776fcb86a7c0f00a898e7ba023@dist-git>
|
|
|
9119d9 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
9119d9 |
Date: Thu, 18 Sep 2014 14:39:58 +0200
|
|
|
9119d9 |
Subject: [PATCH] qemu: Honor hugepages for UMA domains
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1135396
|
|
|
9119d9 |
|
|
|
9119d9 |
There are two ways how to tell qemu to use huge pages. The first one
|
|
|
9119d9 |
is suitable for domains with NUMA nodes: the path to hugetlbfs mount
|
|
|
9119d9 |
is appended to NUMA node definition on the command line. The second
|
|
|
9119d9 |
one is suitable for UMA domains: here there's this global '-mem-path'
|
|
|
9119d9 |
argument that accepts path to the hugetlbfs mount point. However, the
|
|
|
9119d9 |
latter case was not used for all the cases that it should be. For
|
|
|
9119d9 |
instance:
|
|
|
9119d9 |
|
|
|
9119d9 |
<memoryBacking>
|
|
|
9119d9 |
<hugepages>
|
|
|
9119d9 |
<page size='2048' unit='KiB' nodeset='0'/>
|
|
|
9119d9 |
</hugepages>
|
|
|
9119d9 |
</memoryBacking>
|
|
|
9119d9 |
|
|
|
9119d9 |
didn't trigger the '-mem-path' so the huge pages - despite being
|
|
|
9119d9 |
configured - were not used at all.
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit 281f70013e9d6fff7f2d4b55f5133a837f023190)
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_command.c | 25 ++++++++++++++---
|
|
|
9119d9 |
.../qemuxml2argv-hugepages-pages5.args | 7 +++++
|
|
|
9119d9 |
.../qemuxml2argv-hugepages-pages5.xml | 32 ++++++++++++++++++++++
|
|
|
9119d9 |
tests/qemuxml2argvtest.c | 1 +
|
|
|
9119d9 |
4 files changed, 61 insertions(+), 4 deletions(-)
|
|
|
9119d9 |
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages5.args
|
|
|
9119d9 |
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages5.xml
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
9119d9 |
index 45667d9..fb9c453 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_command.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_command.c
|
|
|
9119d9 |
@@ -7685,7 +7685,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|
|
9119d9 |
virCommandAddArg(cmd, "-m");
|
|
|
9119d9 |
def->mem.max_balloon = VIR_DIV_UP(def->mem.max_balloon, 1024) * 1024;
|
|
|
9119d9 |
virCommandAddArgFormat(cmd, "%llu", def->mem.max_balloon / 1024);
|
|
|
9119d9 |
- if (def->mem.nhugepages && !def->mem.hugepages[0].size) {
|
|
|
9119d9 |
+ if (def->mem.nhugepages && (!def->cpu || !def->cpu->ncells)) {
|
|
|
9119d9 |
char *mem_path;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (!cfg->nhugetlbfs) {
|
|
|
9119d9 |
@@ -7701,9 +7701,26 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (!(mem_path = qemuGetDefaultHugepath(cfg->hugetlbfs,
|
|
|
9119d9 |
- cfg->nhugetlbfs)))
|
|
|
9119d9 |
- goto error;
|
|
|
9119d9 |
+ if (def->mem.hugepages[0].size) {
|
|
|
9119d9 |
+ for (j = 0; j < cfg->nhugetlbfs; j++) {
|
|
|
9119d9 |
+ if (cfg->hugetlbfs[j].size == def->mem.hugepages[0].size)
|
|
|
9119d9 |
+ break;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (j == cfg->nhugetlbfs) {
|
|
|
9119d9 |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
9119d9 |
+ _("Unable to find any usable hugetlbfs mount for %llu KiB"),
|
|
|
9119d9 |
+ def->mem.hugepages[0].size);
|
|
|
9119d9 |
+ goto error;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (!(mem_path = qemuGetHugepagePath(&cfg->hugetlbfs[j])))
|
|
|
9119d9 |
+ goto error;
|
|
|
9119d9 |
+ } else {
|
|
|
9119d9 |
+ if (!(mem_path = qemuGetDefaultHugepath(cfg->hugetlbfs,
|
|
|
9119d9 |
+ cfg->nhugetlbfs)))
|
|
|
9119d9 |
+ goto error;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
|
|
|
9119d9 |
virCommandAddArgList(cmd, "-mem-prealloc", "-mem-path",
|
|
|
9119d9 |
mem_path, NULL);
|
|
|
9119d9 |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages5.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages5.args
|
|
|
9119d9 |
new file mode 100644
|
|
|
9119d9 |
index 0000000..0e0f35a
|
|
|
9119d9 |
--- /dev/null
|
|
|
9119d9 |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages5.args
|
|
|
9119d9 |
@@ -0,0 +1,7 @@
|
|
|
9119d9 |
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
|
|
9119d9 |
+/usr/bin/qemu -S -M pc -m 1024 \
|
|
|
9119d9 |
+-mem-prealloc \
|
|
|
9119d9 |
+-mem-path /dev/hugepages2M/libvirt/qemu \
|
|
|
9119d9 |
+-smp 2 -nographic \
|
|
|
9119d9 |
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
|
|
|
9119d9 |
+-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none
|
|
|
9119d9 |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages5.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages5.xml
|
|
|
9119d9 |
new file mode 100644
|
|
|
9119d9 |
index 0000000..50a9cd8
|
|
|
9119d9 |
--- /dev/null
|
|
|
9119d9 |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages5.xml
|
|
|
9119d9 |
@@ -0,0 +1,32 @@
|
|
|
9119d9 |
+<domain type='qemu'>
|
|
|
9119d9 |
+ <name>SomeDummyHugepagesGuest</name>
|
|
|
9119d9 |
+ <uuid>ef1bdff4-27f3-4e85-a807-5fb4d58463cc</uuid>
|
|
|
9119d9 |
+ <memory unit='KiB'>1048576</memory>
|
|
|
9119d9 |
+ <currentMemory unit='KiB'>1048576</currentMemory>
|
|
|
9119d9 |
+ <memoryBacking>
|
|
|
9119d9 |
+ <hugepages>
|
|
|
9119d9 |
+ <page size='2048' unit='KiB'/>
|
|
|
9119d9 |
+ </hugepages>
|
|
|
9119d9 |
+ </memoryBacking>
|
|
|
9119d9 |
+ <vcpu placement='static'>2</vcpu>
|
|
|
9119d9 |
+ <os>
|
|
|
9119d9 |
+ <type arch='i686' machine='pc'>hvm</type>
|
|
|
9119d9 |
+ <boot dev='hd'/>
|
|
|
9119d9 |
+ </os>
|
|
|
9119d9 |
+ <clock offset='utc'/>
|
|
|
9119d9 |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
9119d9 |
+ <on_reboot>restart</on_reboot>
|
|
|
9119d9 |
+ <on_crash>destroy</on_crash>
|
|
|
9119d9 |
+ <devices>
|
|
|
9119d9 |
+ <emulator>/usr/bin/qemu</emulator>
|
|
|
9119d9 |
+ <disk type='block' device='disk'>
|
|
|
9119d9 |
+ <source dev='/dev/HostVG/QEMUGuest1'/>
|
|
|
9119d9 |
+ <target dev='hda' bus='ide'/>
|
|
|
9119d9 |
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
|
|
9119d9 |
+ </disk>
|
|
|
9119d9 |
+ <controller type='usb' index='0'/>
|
|
|
9119d9 |
+ <controller type='ide' index='0'/>
|
|
|
9119d9 |
+ <controller type='pci' index='0' model='pci-root'/>
|
|
|
9119d9 |
+ <memballoon model='virtio'/>
|
|
|
9119d9 |
+ </devices>
|
|
|
9119d9 |
+</domain>
|
|
|
9119d9 |
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
|
|
|
9119d9 |
index 3b5f31a..68fc01b 100644
|
|
|
9119d9 |
--- a/tests/qemuxml2argvtest.c
|
|
|
9119d9 |
+++ b/tests/qemuxml2argvtest.c
|
|
|
9119d9 |
@@ -688,6 +688,7 @@ mymain(void)
|
|
|
9119d9 |
QEMU_CAPS_OBJECT_MEMORY_FILE);
|
|
|
9119d9 |
DO_TEST_FAILURE("hugepages-pages4", QEMU_CAPS_MEM_PATH,
|
|
|
9119d9 |
QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
|
|
|
9119d9 |
+ DO_TEST("hugepages-pages5", QEMU_CAPS_MEM_PATH);
|
|
|
9119d9 |
DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
|
|
|
9119d9 |
DO_TEST("disk-cdrom", NONE);
|
|
|
9119d9 |
DO_TEST("disk-cdrom-network-http", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.1.0
|
|
|
9119d9 |
|