From 25c70c46cff173bcb1f9a051bb07501a0a688e00 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 1 Jul 2015 20:46:00 +0200 Subject: [PATCH 31/31] configure: Add support for tcmalloc Message-id: <1435783560-22369-1-git-send-email-pbonzini@redhat.com> Patchwork-id: 66599 O-Subject: [RHEL7.2 qemu-kvm-rhev PATCH v2] configure: Add support for tcmalloc Bugzilla: 1213882 RH-Acked-by: Laurent Vivier RH-Acked-by: Juan Quintela RH-Acked-by: Stefan Hajnoczi From: Fam Zheng Bugzilla: 1213882 Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=9451417 (qemu-ga) http://brewweb.devel.redhat.com/brew/taskinfo?taskID=9451418 (qemu-kvm-rhev) This adds "--enable-tcmalloc" and "--disable-tcmalloc" to allow linking to libtcmalloc from gperftools. tcmalloc is a malloc implementation that works well with threads and is fast, so it is good for performance. It is disabled by default, because the MALLOC_PERTURB_ flag we use in tests doesn't work with tcmalloc. However we can enable tcmalloc specific heap checker and profilers later. An IOPS gain can be observed with virtio-blk-dataplane, other parts of QEMU will directly benefit from it as well: ========================================================== glibc malloc ---------------------------------------------------------- rw bs iodepth bw iops latency read 4k 1 150 38511 24 ---------------------------------------------------------- ========================================================== tcmalloc ---------------------------------------------------------- rw bs iodepth bw iops latency read 4k 1 156 39969 23 ---------------------------------------------------------- Signed-off-by: Fam Zheng Message-Id: <1427338992-27057-1-git-send-email-famz@redhat.com> Signed-off-by: Paolo Bonzini (cherry picked from commit 2847b46958ab0bd604e1b3fcafba0f5ba4375833) Signed-off-by: Miroslav Rezanina Conflicts: configure Note on the RHEL7 part: malloc(1) would fail to compile due to -D_FORTIFY_SOURCE=2 that configure passes in --extra-cflags. The flag enables warnings for unused result of malloc. However, QEMU already knows about -D_FORTIFY_SOURCE and enables it after configure tests are run. So, remove it from --extra-cflags and trust configure to do the right thing. The have_ flags are a bit messy. --- configure | 24 ++++++++++++++++++++++++ redhat/build_configure.sh | 3 +++ redhat/qemu-guest-agent.spec.template | 13 +++++++++++++ redhat/qemu-kvm.spec.template | 15 +++++++++++++++ 4 files changed, 55 insertions(+) --- configure | 24 ++++++++++++++++++++++++ redhat/build_configure.sh | 3 +++ redhat/qemu-guest-agent.spec.template | 13 +++++++++++++ redhat/qemu-kvm.spec.template | 15 +++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/configure b/configure index f054934..280a1c2 100755 --- a/configure +++ b/configure @@ -337,6 +337,7 @@ vhdx="" quorum="" live_block_migration="no" numa="" +tcmalloc="no" # parse CC options first @@ -1140,6 +1141,10 @@ for opt do ;; --enable-live-block-migration) live_block_migration="yes" ;; + --disable-tcmalloc) tcmalloc="no" + ;; + --enable-tcmalloc) tcmalloc="yes" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1416,6 +1421,8 @@ Advanced options (experts only): --enable-live-block-migration enable live block migration --disable-numa disable libnuma support --enable-numa enable libnuma support + --disable-tcmalloc disable tcmalloc support + --enable-tcmalloc enable tcmalloc support NOTE: The object files are built at the place where configure is launched EOF @@ -3340,6 +3347,22 @@ EOF fi ########################################## +# tcmalloc probe + +if test "$tcmalloc" = "yes" ; then + cat > $TMPC << EOF +#include +int main(void) { malloc(1); return 0; } +EOF + + if compile_prog "" "-ltcmalloc" ; then + LIBS="-ltcmalloc $LIBS" + else + feature_not_found "tcmalloc" "install gperftools devel" + fi +fi + +########################################## # signalfd probe signalfd="no" cat > $TMPC << EOF @@ -4451,6 +4474,7 @@ echo "snappy support $snappy" echo "bzip2 support $bzip2" echo "Live block migration $live_block_migration" echo "NUMA host support $numa" +echo "tcmalloc support $tcmalloc" if test "$sdl_too_old" = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" -- 1.8.3.1