cryptospore / rpms / qemu-kvm

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