9ae3a8
From 7016ef484a8150337f22f45f694c0901c5ae0a26 Mon Sep 17 00:00:00 2001
9ae3a8
From: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Date: Fri, 26 Jun 2015 11:23:50 +0200
9ae3a8
Subject: [PATCH 10/10] configure: Add support for tcmalloc
9ae3a8
9ae3a8
Message-id: <1435317831-6743-1-git-send-email-pbonzini@redhat.com>
9ae3a8
Patchwork-id: 66518
9ae3a8
O-Subject: [RHEL7.2 qemu-kvm PATCH] configure: Add support for tcmalloc
9ae3a8
Bugzilla: 1213881
9ae3a8
RH-Acked-by: Jeff Nelson <jenelson@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
9ae3a8
This adds "--enable-tcmalloc" and "--disable-tcmalloc" to allow linking
9ae3a8
to libtcmalloc from gperftools.
9ae3a8
9ae3a8
tcmalloc is a malloc implementation that works well with threads and is
9ae3a8
fast, so it is good for performance.
9ae3a8
9ae3a8
It is disabled by default, because the MALLOC_PERTURB_ flag we use in
9ae3a8
tests doesn't work with tcmalloc. However we can enable tcmalloc
9ae3a8
specific heap checker and profilers later.
9ae3a8
9ae3a8
An IOPS gain can be observed with virtio-blk-dataplane, other parts of
9ae3a8
QEMU will directly benefit from it as well:
9ae3a8
9ae3a8
==========================================================
9ae3a8
                       glibc malloc
9ae3a8
----------------------------------------------------------
9ae3a8
rw         bs         iodepth    bw     iops       latency
9ae3a8
read       4k         1          150    38511      24
9ae3a8
----------------------------------------------------------
9ae3a8
9ae3a8
==========================================================
9ae3a8
                         tcmalloc
9ae3a8
----------------------------------------------------------
9ae3a8
rw         bs         iodepth    bw     iops       latency
9ae3a8
read       4k         1          156    39969      23
9ae3a8
----------------------------------------------------------
9ae3a8
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Message-Id: <1427338992-27057-1-git-send-email-famz@redhat.com>
9ae3a8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
(cherry picked from commit 2847b46958ab0bd604e1b3fcafba0f5ba4375833)
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	configure
9ae3a8
9ae3a8
Note on the RHEL7 part:
9ae3a8
	malloc(1) would fail to compile due to -D_FORTIFY_SOURCE=2 that
9ae3a8
	configure passes in --extra-cflags.  The flag enables warnings
9ae3a8
        for unused result of malloc.  However, QEMU already knows about
9ae3a8
        -D_FORTIFY_SOURCE and enables it after configure tests are run.
9ae3a8
	So, remove it from --extra-cflags and trust configure to do the
9ae3a8
	right thing.
9ae3a8
---
9ae3a8
 configure                     | 24 ++++++++++++++++++++++++
9ae3a8
 redhat/qemu-kvm.spec.template | 10 ++++++++++
9ae3a8
 2 files changed, 34 insertions(+)
9ae3a8
9ae3a8
diff --git a/configure b/configure
9ae3a8
index 85dbfb0..5877e82 100755
9ae3a8
--- a/configure
9ae3a8
+++ b/configure
9ae3a8
@@ -250,6 +250,7 @@ libssh2=""
9ae3a8
 live_block_ops="yes"
9ae3a8
 live_block_migration="no"
9ae3a8
 vhdx=""
9ae3a8
+tcmalloc="no"
9ae3a8
 
9ae3a8
 # parse CC options first
9ae3a8
 for opt do
9ae3a8
@@ -972,6 +973,10 @@ for opt do
9ae3a8
   ;;
9ae3a8
   --disable-vhdx) vhdx="no"
9ae3a8
   ;;
9ae3a8
+  --disable-tcmalloc) tcmalloc="no"
9ae3a8
+  ;;
9ae3a8
+  --enable-tcmalloc) tcmalloc="yes"
9ae3a8
+  ;;
9ae3a8
   *) echo "ERROR: unknown option $opt"; show_help="yes"
9ae3a8
   ;;
9ae3a8
   esac
9ae3a8
@@ -1253,6 +1258,8 @@ echo "  --disable-live-block-migration disable live block migration"
9ae3a8
 echo "  --enable-live-block-migration  enable live block migration"
9ae3a8
 echo "  --disable-vhdx           disables support for the Microsoft VHDX image format"
9ae3a8
 echo "  --enable-vhdx            enable support for the Microsoft VHDX image format"
9ae3a8
+echo "  --disable-tcmalloc       disable tcmalloc support"
9ae3a8
+echo "  --enable-tcmalloc        enable tcmalloc support"
9ae3a8
 echo ""
9ae3a8
 echo "NOTE: The object files are built at the place where configure is launched"
9ae3a8
 exit 1
9ae3a8
@@ -2878,6 +2885,22 @@ if compile_prog "" "" ; then
9ae3a8
 fi
9ae3a8
 
9ae3a8
 ##########################################
9ae3a8
+# tcmalloc probe
9ae3a8
+
9ae3a8
+if test "$tcmalloc" = "yes" ; then
9ae3a8
+  cat > $TMPC << EOF
9ae3a8
+#include <stdlib.h>
9ae3a8
+int main(void) { malloc(1); return 0; }
9ae3a8
+EOF
9ae3a8
+
9ae3a8
+  if compile_prog "" "-ltcmalloc" ; then
9ae3a8
+    LIBS="-ltcmalloc $LIBS"
9ae3a8
+  else
9ae3a8
+    feature_not_found "tcmalloc" "install gperftools devel"
9ae3a8
+  fi
9ae3a8
+fi
9ae3a8
+
9ae3a8
+##########################################
9ae3a8
 # signalfd probe
9ae3a8
 signalfd="no"
9ae3a8
 cat > $TMPC << EOF
9ae3a8
@@ -3744,6 +3767,7 @@ echo "Live block migration $live_block_migration"
9ae3a8
 echo "vhdx              $vhdx"
9ae3a8
 echo "lzo support       $lzo"
9ae3a8
 echo "snappy support    $snappy"
9ae3a8
+echo "tcmalloc support  $tcmalloc"
9ae3a8
 
9ae3a8
 if test "$sdl_too_old" = "yes"; then
9ae3a8
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8