|
|
3e5111 |
From 766ccea976922a5da2f76e26fc37e03ac14ecacd Mon Sep 17 00:00:00 2001
|
|
|
3e5111 |
Message-Id: <766ccea976922a5da2f76e26fc37e03ac14ecacd@dist-git>
|
|
|
3e5111 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
3e5111 |
Date: Wed, 14 Jun 2017 16:58:12 +0200
|
|
|
3e5111 |
Subject: [PATCH] qemu: Prefer hugepages over mem source='file'
|
|
|
3e5111 |
|
|
|
3e5111 |
https://bugzilla.redhat.com/show_bug.cgi?id=1214369
|
|
|
3e5111 |
|
|
|
3e5111 |
Consider the following XML:
|
|
|
3e5111 |
|
|
|
3e5111 |
<memoryBacking>
|
|
|
3e5111 |
<hugepages>
|
|
|
3e5111 |
<page size='2048' unit='KiB' nodeset='1'/>
|
|
|
3e5111 |
</hugepages>
|
|
|
3e5111 |
<source type='file'/>
|
|
|
3e5111 |
<access mode='shared'/>
|
|
|
3e5111 |
</memoryBacking>
|
|
|
3e5111 |
|
|
|
3e5111 |
<numa>
|
|
|
3e5111 |
<cell id='0' cpus='0-3' memory='512000' unit='KiB'/>
|
|
|
3e5111 |
<cell id='1' cpus='4-7' memory='512000' unit='KiB'/>
|
|
|
3e5111 |
</numa>
|
|
|
3e5111 |
|
|
|
3e5111 |
The following cmd line is generated:
|
|
|
3e5111 |
|
|
|
3e5111 |
-object
|
|
|
3e5111 |
memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,
|
|
|
3e5111 |
share=yes,size=524288000 -numa node,nodeid=0,cpus=0-3,memdev=ram-node0
|
|
|
3e5111 |
-object
|
|
|
3e5111 |
memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,
|
|
|
3e5111 |
share=yes,size=524288000 -numa node,nodeid=1,cpus=4-7,memdev=ram-node1
|
|
|
3e5111 |
|
|
|
3e5111 |
This is obviously wrong as for node 1 hugepages should have been
|
|
|
3e5111 |
used. The hugepages configuration is more specific than
|
|
|
3e5111 |
type='file'/>.
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
3e5111 |
(cherry picked from commit 992bf863fccfe1fa1d0c5a5277b9cee50abc48ef)
|
|
|
3e5111 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
---
|
|
|
3e5111 |
src/qemu/qemu_command.c | 6 +--
|
|
|
3e5111 |
.../qemuxml2argv-hugepages-memaccess2.args | 39 ++++++++++++++
|
|
|
3e5111 |
.../qemuxml2argv-hugepages-memaccess2.xml | 62 ++++++++++++++++++++++
|
|
|
3e5111 |
tests/qemuxml2argvtest.c | 3 ++
|
|
|
3e5111 |
.../qemuxml2xmlout-hugepages-memaccess2.xml | 1 +
|
|
|
3e5111 |
tests/qemuxml2xmltest.c | 1 +
|
|
|
3e5111 |
6 files changed, 109 insertions(+), 3 deletions(-)
|
|
|
3e5111 |
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args
|
|
|
3e5111 |
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml
|
|
|
3e5111 |
create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
3e5111 |
index c791214528..5013d3149d 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_command.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_command.c
|
|
|
3e5111 |
@@ -3413,9 +3413,9 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
|
|
|
3e5111 |
if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
prealloc = true;
|
|
|
3e5111 |
- } else if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
|
|
|
3e5111 |
- /* We can have both pagesize and mem source,
|
|
|
3e5111 |
- * then check mem source first. */
|
|
|
3e5111 |
+ } else if (!pagesize && def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
|
|
|
3e5111 |
+ /* We can have both pagesize and mem source. If that's the case,
|
|
|
3e5111 |
+ * prefer hugepages as those are more specific. */
|
|
|
3e5111 |
if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
} else {
|
|
|
3e5111 |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args
|
|
|
3e5111 |
new file mode 100644
|
|
|
3e5111 |
index 0000000000..11985232a7
|
|
|
3e5111 |
--- /dev/null
|
|
|
3e5111 |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.args
|
|
|
3e5111 |
@@ -0,0 +1,39 @@
|
|
|
3e5111 |
+LC_ALL=C \
|
|
|
3e5111 |
+PATH=/bin \
|
|
|
3e5111 |
+HOME=/home/test \
|
|
|
3e5111 |
+USER=test \
|
|
|
3e5111 |
+LOGNAME=test \
|
|
|
3e5111 |
+QEMU_AUDIO_DRV=none \
|
|
|
3e5111 |
+/usr/bin/qemu-system-i686 \
|
|
|
3e5111 |
+-name QEMUGuest1 \
|
|
|
3e5111 |
+-S \
|
|
|
3e5111 |
+-M pc \
|
|
|
3e5111 |
+-m size=4194304k,slots=16,maxmem=8388608k \
|
|
|
3e5111 |
+-smp 4,sockets=4,cores=1,threads=1 \
|
|
|
3e5111 |
+-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
|
|
|
3e5111 |
+share=no,size=1073741824,host-nodes=0-3,policy=bind \
|
|
|
3e5111 |
+-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
|
|
|
3e5111 |
+-object memory-backend-file,id=ram-node1,prealloc=yes,\
|
|
|
3e5111 |
+mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=1073741824,\
|
|
|
3e5111 |
+host-nodes=0-3,policy=bind \
|
|
|
3e5111 |
+-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
|
|
|
3e5111 |
+-object memory-backend-file,id=ram-node2,mem-path=/var/lib/libvirt/qemu/ram,\
|
|
|
3e5111 |
+share=no,size=1073741824,host-nodes=0-3,policy=bind \
|
|
|
3e5111 |
+-numa node,nodeid=2,cpus=2,memdev=ram-node2 \
|
|
|
3e5111 |
+-object memory-backend-file,id=ram-node3,mem-path=/var/lib/libvirt/qemu/ram,\
|
|
|
3e5111 |
+share=no,size=1073741824,host-nodes=3,policy=bind \
|
|
|
3e5111 |
+-numa node,nodeid=3,cpus=3,memdev=ram-node3 \
|
|
|
3e5111 |
+-object memory-backend-file,id=memdimm0,prealloc=yes,\
|
|
|
3e5111 |
+mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=536870912,\
|
|
|
3e5111 |
+host-nodes=0-3,policy=bind \
|
|
|
3e5111 |
+-device pc-dimm,node=1,memdev=memdimm0,id=dimm0,slot=0,addr=4294967296 \
|
|
|
3e5111 |
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
|
|
|
3e5111 |
+-nographic \
|
|
|
3e5111 |
+-nodefaults \
|
|
|
3e5111 |
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
|
|
|
3e5111 |
+-no-acpi \
|
|
|
3e5111 |
+-boot c \
|
|
|
3e5111 |
+-usb \
|
|
|
3e5111 |
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
|
|
|
3e5111 |
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
|
|
|
3e5111 |
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
|
|
3e5111 |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml
|
|
|
3e5111 |
new file mode 100644
|
|
|
3e5111 |
index 0000000000..c0011285c2
|
|
|
3e5111 |
--- /dev/null
|
|
|
3e5111 |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml
|
|
|
3e5111 |
@@ -0,0 +1,62 @@
|
|
|
3e5111 |
+<domain type='qemu'>
|
|
|
3e5111 |
+ <name>QEMUGuest1</name>
|
|
|
3e5111 |
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
|
|
3e5111 |
+ <maxMemory slots='16' unit='KiB'>8388608</maxMemory>
|
|
|
3e5111 |
+ <memory unit='KiB'>4194304</memory>
|
|
|
3e5111 |
+ <currentMemory unit='KiB'>4194304</currentMemory>
|
|
|
3e5111 |
+ <memoryBacking>
|
|
|
3e5111 |
+ <hugepages>
|
|
|
3e5111 |
+ <page size='2048' unit='KiB' nodeset='1'/>
|
|
|
3e5111 |
+ </hugepages>
|
|
|
3e5111 |
+ <source type='file'/>
|
|
|
3e5111 |
+ <access mode='private'/>
|
|
|
3e5111 |
+ </memoryBacking>
|
|
|
3e5111 |
+ <vcpu placement='static'>4</vcpu>
|
|
|
3e5111 |
+ <numatune>
|
|
|
3e5111 |
+ <memory mode='strict' nodeset='0-3'/>
|
|
|
3e5111 |
+ <memnode cellid='3' mode='strict' nodeset='3'/>
|
|
|
3e5111 |
+ </numatune>
|
|
|
3e5111 |
+ <os>
|
|
|
3e5111 |
+ <type arch='i686' machine='pc'>hvm</type>
|
|
|
3e5111 |
+ <boot dev='hd'/>
|
|
|
3e5111 |
+ </os>
|
|
|
3e5111 |
+ <cpu>
|
|
|
3e5111 |
+ <numa>
|
|
|
3e5111 |
+ <cell id='0' cpus='0' memory='1048576' unit='KiB'/>
|
|
|
3e5111 |
+ <cell id='1' cpus='1' memory='1048576' unit='KiB' memAccess='shared'/>
|
|
|
3e5111 |
+ <cell id='2' cpus='2' memory='1048576' unit='KiB' memAccess='private'/>
|
|
|
3e5111 |
+ <cell id='3' cpus='3' memory='1048576' unit='KiB'/>
|
|
|
3e5111 |
+ </numa>
|
|
|
3e5111 |
+ </cpu>
|
|
|
3e5111 |
+ <clock offset='utc'/>
|
|
|
3e5111 |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
3e5111 |
+ <on_reboot>restart</on_reboot>
|
|
|
3e5111 |
+ <on_crash>destroy</on_crash>
|
|
|
3e5111 |
+ <devices>
|
|
|
3e5111 |
+ <emulator>/usr/bin/qemu-system-i686</emulator>
|
|
|
3e5111 |
+ <disk type='block' device='disk'>
|
|
|
3e5111 |
+ <source dev='/dev/HostVG/QEMUGuest1'/>
|
|
|
3e5111 |
+ <target dev='hda' bus='ide'/>
|
|
|
3e5111 |
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
|
|
3e5111 |
+ </disk>
|
|
|
3e5111 |
+ <controller type='usb' index='0'>
|
|
|
3e5111 |
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
|
|
3e5111 |
+ </controller>
|
|
|
3e5111 |
+ <controller type='ide' index='0'>
|
|
|
3e5111 |
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
|
|
3e5111 |
+ </controller>
|
|
|
3e5111 |
+ <controller type='pci' index='0' model='pci-root'/>
|
|
|
3e5111 |
+ <input type='mouse' bus='ps2'/>
|
|
|
3e5111 |
+ <input type='keyboard' bus='ps2'/>
|
|
|
3e5111 |
+ <memballoon model='virtio'>
|
|
|
3e5111 |
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
|
|
3e5111 |
+ </memballoon>
|
|
|
3e5111 |
+ <memory model='dimm'>
|
|
|
3e5111 |
+ <target>
|
|
|
3e5111 |
+ <size unit='KiB'>524288</size>
|
|
|
3e5111 |
+ <node>1</node>
|
|
|
3e5111 |
+ </target>
|
|
|
3e5111 |
+ <address type='dimm' slot='0' base='0x100000000'/>
|
|
|
3e5111 |
+ </memory>
|
|
|
3e5111 |
+ </devices>
|
|
|
3e5111 |
+</domain>
|
|
|
3e5111 |
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
|
|
|
3e5111 |
index 77e52bd33b..98e70033ec 100644
|
|
|
3e5111 |
--- a/tests/qemuxml2argvtest.c
|
|
|
3e5111 |
+++ b/tests/qemuxml2argvtest.c
|
|
|
3e5111 |
@@ -830,6 +830,9 @@ mymain(void)
|
|
|
3e5111 |
DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE,
|
|
|
3e5111 |
QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
|
|
|
3e5111 |
QEMU_CAPS_NUMA);
|
|
|
3e5111 |
+ DO_TEST("hugepages-memaccess2", QEMU_CAPS_OBJECT_MEMORY_FILE,
|
|
|
3e5111 |
+ QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
|
|
|
3e5111 |
+ QEMU_CAPS_NUMA);
|
|
|
3e5111 |
DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
|
|
|
3e5111 |
DO_TEST("disk-cdrom", NONE);
|
|
|
3e5111 |
DO_TEST("disk-iscsi", NONE);
|
|
|
3e5111 |
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml
|
|
|
3e5111 |
new file mode 120000
|
|
|
3e5111 |
index 0000000000..3f7a38333f
|
|
|
3e5111 |
--- /dev/null
|
|
|
3e5111 |
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-hugepages-memaccess2.xml
|
|
|
3e5111 |
@@ -0,0 +1 @@
|
|
|
3e5111 |
+../qemuxml2argvdata/qemuxml2argv-hugepages-memaccess2.xml
|
|
|
3e5111 |
\ No newline at end of file
|
|
|
3e5111 |
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
|
|
|
3e5111 |
index 511d1b3fb9..f2abad00cf 100644
|
|
|
3e5111 |
--- a/tests/qemuxml2xmltest.c
|
|
|
3e5111 |
+++ b/tests/qemuxml2xmltest.c
|
|
|
3e5111 |
@@ -421,6 +421,7 @@ mymain(void)
|
|
|
3e5111 |
DO_TEST("hugepages-pages3", NONE);
|
|
|
3e5111 |
DO_TEST("hugepages-shared", NONE);
|
|
|
3e5111 |
DO_TEST("hugepages-memaccess", NONE);
|
|
|
3e5111 |
+ DO_TEST("hugepages-memaccess2", NONE);
|
|
|
3e5111 |
DO_TEST("nosharepages", NONE);
|
|
|
3e5111 |
DO_TEST("restore-v2", NONE);
|
|
|
3e5111 |
DO_TEST("migrate", NONE);
|
|
|
3e5111 |
--
|
|
|
3e5111 |
2.13.1
|
|
|
3e5111 |
|