Re: [Qemu-devel] [PATCH/RFC] loader: enable roms, kernel and firmware files for KSM sharing
Hi, Your series failed automatic build test. Please find the testing commands and their output below. If you have docker installed, you can probably reproduce it locally. Type: series Message-id: 1474379311-76684-1-git-send-email-borntrae...@de.ibm.com Subject: [Qemu-devel] [PATCH/RFC] loader: enable roms, kernel and firmware files for KSM sharing === TEST SCRIPT BEGIN === #!/bin/bash set -e git submodule update --init dtc make J=8 docker-test-quick@centos6 make J=8 docker-test-mingw@fedora === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test' 1f2c0fd loader: enable roms, kernel and firmware files for KSM sharing === OUTPUT BEGIN === Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into 'dtc'... Submodule path 'dtc': checked out '65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf' BUILD centos6 ARCHIVE qemu.tgz ARCHIVE dtc.tgz COPY RUNNER RUN test-quick in centos6 No C++ compiler available; disabling C++ specific optional code Install prefix/tmp/qemu-test/src/tests/docker/install BIOS directory/tmp/qemu-test/src/tests/docker/install/share/qemu binary directory /tmp/qemu-test/src/tests/docker/install/bin library directory /tmp/qemu-test/src/tests/docker/install/lib module directory /tmp/qemu-test/src/tests/docker/install/lib/qemu libexec directory /tmp/qemu-test/src/tests/docker/install/libexec include directory /tmp/qemu-test/src/tests/docker/install/include config directory /tmp/qemu-test/src/tests/docker/install/etc local state directory /tmp/qemu-test/src/tests/docker/install/var Manual directory /tmp/qemu-test/src/tests/docker/install/share/man ELF interp prefix /usr/gnemul/qemu-%M Source path /tmp/qemu-test/src C compilercc Host C compiler cc C++ compiler Objective-C compiler cc ARFLAGS rv CFLAGS-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -g QEMU_CFLAGS -I/usr/include/pixman-1-fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all LDFLAGS -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g make make install install pythonpython -B smbd /usr/sbin/smbd module supportno host CPU x86_64 host big endian no target list x86_64-softmmu aarch64-softmmu tcg debug enabled no gprof enabled no sparse enabledno strip binariesyes profiler no static build no pixmansystem SDL support yes (1.2.14) GTK support no GTK GL supportno VTE support no TLS priority NORMAL GNUTLS supportno GNUTLS rndno libgcrypt no libgcrypt kdf no nettleno nettle kdfno libtasn1 no curses supportno virgl support no curl support no mingw32 support no Audio drivers oss Block whitelist (rw) Block whitelist (ro) VirtFS supportno VNC support yes VNC SASL support no VNC JPEG support no VNC PNG support no xen support no brlapi supportno bluez supportno Documentation no PIE yes vde support no netmap supportno Linux AIO support no ATTR/XATTR support yes Install blobs yes KVM support yes RDMA support no TCG interpreter no fdt support yes preadv supportyes fdatasync yes madvise yes posix_madvise yes uuid support no libcap-ng support no vhost-net support yes vhost-scsi support yes vhost-vsock support yes Trace backendslog spice support no rbd support no xfsctl supportno smartcard support no libusbno usb net redir no OpenGL supportno OpenGL dmabufsno libiscsi support no libnfs supportno build guest agent yes QGA VSS support no QGA w32 disk info no QGA MSI support no seccomp support no coroutine backend ucontext coroutine poolyes GlusterFS support no Archipelago support no gcov gcov gcov enabled no TPM support yes libssh2 support no TPM passthrough yes QOM debugging yes vhdx no lzo support no snappy supportno bzip2 support no NUMA host support no tcmalloc support no jemalloc support no avx2 optimization no replication support yes GEN x86_64-softmmu/config-devices.mak.tmp GEN aarch64-softmmu/config-devices.mak.tmp GEN config-host.h GEN qemu-options.def GEN qmp-commands.h GEN qapi-types.h GEN qapi-visit.h GEN qapi-event.h GEN x86_
[Qemu-devel] [PATCH/RFC] loader: enable roms, kernel and firmware files for KSM sharing
Early patch for feedback. With lots of similar small guests a big part of memory is consumed by the ROMs that are reloaded at each start. We can reduce the memory consumption by allowing KSM on this data. This patches reduces the memory consumption of 200 guests with a vmlinux as kernel + busybox ramdisk by 4GB after KSM has done its job on s390. A similar approach could be done in hw/i386/pc.c. Signed-off-by: Christian Borntraeger --- hw/core/loader.c | 10 ++ include/hw/elf_ops.h | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/core/loader.c b/hw/core/loader.c index 53e0e41..def427c 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -867,7 +867,7 @@ int rom_add_file(const char *file, const char *fw_dir, } rom->datasize = rom->romsize; -rom->data = g_malloc0(rom->datasize); +rom->data = qemu_memalign(getpagesize(), rom->datasize); lseek(fd, 0, SEEK_SET); rc = read(fd, rom->data, rom->datasize); if (rc != rom->datasize) { @@ -875,6 +875,7 @@ int rom_add_file(const char *file, const char *fw_dir, rom->name, rc, rom->datasize); goto err; } +qemu_madvise(rom->data, rom->datasize, MADV_MERGEABLE); close(fd); rom_insert(rom); if (rom->fw_file && fw_cfg) { @@ -915,7 +916,7 @@ err: if (fd != -1) close(fd); -g_free(rom->data); +free(rom->data); g_free(rom->path); g_free(rom->name); if (fw_dir) { @@ -940,8 +941,9 @@ MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len, rom->addr = addr; rom->romsize = max_len ? max_len : len; rom->datasize = len; -rom->data = g_malloc0(rom->datasize); +rom->data = qemu_memalign(getpagesize(), rom->datasize); memcpy(rom->data, blob, len); +qemu_madvise(rom->data, rom->datasize, MADV_MERGEABLE); rom_insert(rom); if (fw_file_name && fw_cfg) { char devpath[100]; @@ -1013,7 +1015,7 @@ static void rom_reset(void *unused) } if (rom->isrom) { /* rom needs to be written only once */ -g_free(rom->data); +free(rom->data); rom->data = NULL; } /* diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index f510e7e..aef6713 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -348,6 +348,8 @@ static int glue(load_elf, SZ)(const char *name, int fd, mem_size = ph->p_memsz; /* Size of the ROM */ file_size = ph->p_filesz; /* Size of the allocated data */ data = g_malloc0(file_size); +data = qemu_memalign(getpagesize(), file_size); +qemu_madvise(data, file_size, MADV_MERGEABLE); if (ph->p_filesz > 0) { if (lseek(fd, ph->p_offset, SEEK_SET) < 0) { goto fail; -- 2.5.5