thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
Blob Blame History Raw
From 7016ef484a8150337f22f45f694c0901c5ae0a26 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Fri, 26 Jun 2015 11:23:50 +0200
Subject: [PATCH 10/10] configure: Add support for tcmalloc

Message-id: <1435317831-6743-1-git-send-email-pbonzini@redhat.com>
Patchwork-id: 66518
O-Subject: [RHEL7.2 qemu-kvm PATCH] configure: Add support for tcmalloc
Bugzilla: 1213881
RH-Acked-by: Jeff Nelson <jenelson@redhat.com>
RH-Acked-by: Fam Zheng <famz@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>

From: Fam Zheng <famz@redhat.com>

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 <famz@redhat.com>
Message-Id: <1427338992-27057-1-git-send-email-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 2847b46958ab0bd604e1b3fcafba0f5ba4375833)
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>

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.
---
 configure                     | 24 ++++++++++++++++++++++++
 redhat/qemu-kvm.spec.template | 10 ++++++++++
 2 files changed, 34 insertions(+)

diff --git a/configure b/configure
index 85dbfb0..5877e82 100755
--- a/configure
+++ b/configure
@@ -250,6 +250,7 @@ libssh2=""
 live_block_ops="yes"
 live_block_migration="no"
 vhdx=""
+tcmalloc="no"
 
 # parse CC options first
 for opt do
@@ -972,6 +973,10 @@ for opt do
   ;;
   --disable-vhdx) vhdx="no"
   ;;
+  --disable-tcmalloc) tcmalloc="no"
+  ;;
+  --enable-tcmalloc) tcmalloc="yes"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -1253,6 +1258,8 @@ echo "  --disable-live-block-migration disable live block migration"
 echo "  --enable-live-block-migration  enable live block migration"
 echo "  --disable-vhdx           disables support for the Microsoft VHDX image format"
 echo "  --enable-vhdx            enable support for the Microsoft VHDX image format"
+echo "  --disable-tcmalloc       disable tcmalloc support"
+echo "  --enable-tcmalloc        enable tcmalloc support"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -2878,6 +2885,22 @@ if compile_prog "" "" ; then
 fi
 
 ##########################################
+# tcmalloc probe
+
+if test "$tcmalloc" = "yes" ; then
+  cat > $TMPC << EOF
+#include <stdlib.h>
+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
@@ -3744,6 +3767,7 @@ echo "Live block migration $live_block_migration"
 echo "vhdx              $vhdx"
 echo "lzo support       $lzo"
 echo "snappy support    $snappy"
+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