]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Conditional-compile against minimal tcmalloc.
authorThorsten Behrens <tbehrens@suse.com>
Sun, 15 Mar 2015 23:13:38 +0000 (00:13 +0100)
committerNathan Cutler <ncutler@suse.cz>
Mon, 20 Apr 2015 13:15:44 +0000 (15:15 +0200)
Certain older systems (SLE11 in this case) do not provide the full
tcmalloc functionality, due to e.g. incomplete libunwind
functionality. Use --with-tcmalloc-minimal to enable the cut-down
version. Fixes bnc#882430.

(cherry picked from commit 17e23ed92374726b7c7ecb179230c2069997c9ca)

configure.ac
src/Makefile-env.am
src/perfglue/Makefile.am
src/perfglue/heap_profiler.cc

index 241366e112253fef6fb68454e28d9f05183fb887..b5720daface46586a6bb664ffefd7eb6dea77c30 100644 (file)
@@ -500,6 +500,26 @@ AS_IF([test "x$with_jemalloc" = xyes],
                  [no jemalloc found (do not use --with-jemalloc)])])])
 AM_CONDITIONAL(WITH_JEMALLOC, [test "$HAVE_LIBJEMALLOC" = "1"])
 
+# tcmalloc-minimal?
+AC_ARG_WITH([tcmalloc-minimal],
+           [AS_HELP_STRING([--with-tcmalloc-minimal], [enable minimal tcmalloc support for memory allocations])],
+           [],
+           [with_tcmalloc_minimal=no])
+
+AS_IF([test "x$with_jemalloc" = "xyes"],[with_tcmalloc_minimal=no],[])
+
+TCMALLOC_MINIMAL=
+AS_IF([test "x$with_tcmalloc_minimal" != xno],
+        [AC_CHECK_LIB([tcmalloc_minimal], [malloc],
+         [AC_SUBST([LIBTCMALLOC], ["-ltcmalloc_minimal"])
+              AC_DEFINE([HAVE_LIBTCMALLOC_MINIMAL], [1],
+                        [Define if you have tcmalloc])
+              HAVE_LIBTCMALLOC_MINIMAL=1
+            ],
+           [AC_MSG_FAILURE(
+                 [no tcmalloc found (do not use --with-tcmalloc-minimal)])])])
+AM_CONDITIONAL(WITH_TCMALLOC_MINIMAL, [test "$HAVE_LIBTCMALLOC_MINIMAL" = "1"])
+
 # tcmalloc?
 AC_ARG_WITH([tcmalloc],
            [AS_HELP_STRING([--without-tcmalloc], [disable tcmalloc for memory allocations])],
@@ -507,6 +527,7 @@ AC_ARG_WITH([tcmalloc],
            [with_tcmalloc=yes])
 
 AS_IF([test "x$with_jemalloc" = "xyes"],[with_tcmalloc=no],[])
+AS_IF([test "x$with_tcmalloc_minimal" = "xyes"],[with_tcmalloc=no],[])
 
 TCMALLOC=
 AS_IF([test "x$with_tcmalloc" != xno],
index 93d5a9a0b55d457e4bd62c04a753d6efa117f346..6975e2da1f8d09fe0cc57d46a7feb1698de377a9 100644 (file)
@@ -175,6 +175,10 @@ if WITH_LIBROCKSDB
 LIBOS += libos_rocksdb.la
 endif # WITH_LIBROCKSDB
 
+if WITH_TCMALLOC_MINIMAL
+LIBPERFGLUE += -ltcmalloc_minimal
+endif # WITH_TCMALLOC_MINIMAL
+
 if WITH_TCMALLOC
 LIBPERFGLUE += -ltcmalloc
 endif # WITH_TCMALLOC
index f2b8d5030e641ae2faeecd2f9147ecb310c7a001..c4514a03c28cf327a5cc565bb7fa69712dad6783 100644 (file)
@@ -6,7 +6,14 @@ libperfglue_la_LIBADD = -ltcmalloc
 AM_CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
 AM_CXXFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
 else
+if WITH_TCMALLOC_MINIMAL
+libperfglue_la_SOURCES += perfglue/heap_profiler.cc
+libperfglue_la_LIBADD = -ltcmalloc_minimal
+AM_CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
+AM_CXXFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
+else
 libperfglue_la_SOURCES += perfglue/disabled_heap_profiler.cc
+endif # WITH_TCMALLOC_MINIMAL
 endif # WITH_TCMALLOC
 
 if WITH_PROFILER
index 0fe1f9a43db7d22f1d9b1046068c18080a61d9b3..a0307ca204d95bf8becb2052373f2a07ed5f322d 100644 (file)
@@ -61,7 +61,11 @@ void ceph_heap_release_free_memory()
 
 bool ceph_heap_profiler_running()
 {
+#ifdef HAVE_LIBTCMALLOC
   return IsHeapProfilerRunning();
+#else
+  return false;
+#endif
 }
 
 static void get_profile_name(char *profile_name, int profile_name_len)
@@ -83,21 +87,27 @@ static void get_profile_name(char *profile_name, int profile_name_len)
 
 void ceph_heap_profiler_start()
 {
+#ifdef HAVE_LIBTCMALLOC
   char profile_name[PATH_MAX];
   get_profile_name(profile_name, sizeof(profile_name)); 
   generic_dout(0) << "turning on heap profiler with prefix "
                  << profile_name << dendl;
   HeapProfilerStart(profile_name);
+#endif
 }
 
 void ceph_heap_profiler_stop()
 {
+#ifdef HAVE_LIBTCMALLOC
   HeapProfilerStop();
+#endif
 }
 
 void ceph_heap_profiler_dump(const char *reason)
 {
+#ifdef HAVE_LIBTCMALLOC
   HeapProfilerDump(reason);
+#endif
 }
 
 #define HEAP_PROFILER_STATS_SIZE 2048
@@ -105,6 +115,7 @@ void ceph_heap_profiler_dump(const char *reason)
 void ceph_heap_profiler_handle_command(const std::vector<std::string>& cmd,
                                        ostream& out)
 {
+#ifdef HAVE_LIBTCMALLOC
   if (cmd.size() == 1 && cmd[0] == "dump") {
     if (!ceph_heap_profiler_running()) {
       out << "heap profiler not running; can't dump";
@@ -124,7 +135,9 @@ void ceph_heap_profiler_handle_command(const std::vector<std::string>& cmd,
   } else if (cmd.size() == 1 && cmd[0] == "release") {
     ceph_heap_release_free_memory();
     out << g_conf->name << " releasing free RAM back to system.";
-  } else if (cmd.size() == 1 && cmd[0] == "stats") {
+  } else
+#endif
+  if (cmd.size() == 1 && cmd[0] == "stats") {
     char heap_stats[HEAP_PROFILER_STATS_SIZE];
     ceph_heap_profiler_stats(heap_stats, sizeof(heap_stats));
     out << g_conf->name << " tcmalloc heap stats:"