Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build/ops: linking ceph to tcmalloc causes segfault on SUSE SLE11-SP3 #5265

Merged
1 commit merged into from Jul 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions configure.ac
Expand Up @@ -500,13 +500,34 @@ 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])],
[],
[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],
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile-env.am
Expand Up @@ -178,6 +178,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
Expand Down
7 changes: 7 additions & 0 deletions src/perfglue/Makefile.am
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion src/perfglue/heap_profiler.cc
Expand Up @@ -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)
Expand All @@ -83,28 +87,35 @@ 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

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";
Expand All @@ -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:"
Expand Down