From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Michael Petlan <mpetlan@redhat.com>,
Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 1/3] perf tools: Allow to build with -ltcmalloc
Date: Sun, 13 Oct 2019 17:14:25 +0200 [thread overview]
Message-ID: <20191013151427.11941-2-jolsa@kernel.org> (raw)
In-Reply-To: <20191013151427.11941-1-jolsa@kernel.org>
By using "make TCMALLOC=1" you can enable perf to be build
for usage with libtcmalloc.so (gperftools).
Get heap profile (tools/perf directory):
$ <install gperftools>
$ make TCMALLOC=1 DEBUG=1
$ HEAPPROFILE=/tmp/heapprof ./perf ...
$ pprof ./perf /tmp/heapprof.000*
(pprof) top
Total: 2335.5 MB
1735.1 74.3% 74.3% 1735.1 74.3% memdup
402.0 17.2% 91.5% 402.0 17.2% zalloc
140.2 6.0% 97.5% 145.8 6.2% map__new
33.6 1.4% 98.9% 33.6 1.4% symbol__new
12.4 0.5% 99.5% 12.4 0.5% alloc_event
6.2 0.3% 99.7% 6.2 0.3% nsinfo__new
5.5 0.2% 100.0% 5.5 0.2% nsinfo__copy
0.3 0.0% 100.0% 0.3 0.0% dso__new
0.1 0.0% 100.0% 0.1 0.0% do_read_string
0.0 0.0% 100.0% 0.0 0.0% __GI__IO_file_doallocate
See callstack:
$ pprof --pdf ./perf /tmp/heapprof.00* > callstack.pdf
$ pprof --web ./perf /tmp/heapprof.00*
Link: http://lkml.kernel.org/n/tip-qyo3c7z69dysk10sr3pf5k05@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/Makefile.config | 5 +++++
tools/perf/Makefile.perf | 2 ++
2 files changed, 7 insertions(+)
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 063202c53b64..1783427da9b0 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -265,6 +265,11 @@ LDFLAGS += -Wl,-z,noexecstack
EXTLIBS = -lpthread -lrt -lm -ldl
+ifneq ($(TCMALLOC),)
+ CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
+ EXTLIBS += -ltcmalloc
+endif
+
ifeq ($(FEATURES_DUMP),)
include $(srctree)/tools/build/Makefile.feature
else
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index a099a8a89447..8f1ba986d3bf 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -114,6 +114,8 @@ include ../scripts/utilities.mak
# Define NO_LIBZSTD if you do not want support of Zstandard based runtime
# trace compression in record mode.
#
+# Define TCMALLOC to enable tcmalloc heap profiling.
+#
# As per kernel Makefile, avoid funny character set dependencies
unexport LC_ALL
--
2.21.0
next prev parent reply other threads:[~2019-10-13 15:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-13 15:14 [PATCH 0/3] perf tools: Share struct map after clone Jiri Olsa
2019-10-13 15:14 ` Jiri Olsa [this message]
2019-10-14 1:33 ` [PATCH 1/3] perf tools: Allow to build with -ltcmalloc Andi Kleen
2019-10-14 14:01 ` Arnaldo Carvalho de Melo
2019-10-21 23:19 ` [tip: perf/core] " tip-bot2 for Jiri Olsa
2019-10-13 15:14 ` [PATCH 2/3] perf tools: Separate shareable part of 'struct map' into 'struct map_shared' Jiri Olsa
2019-10-13 15:14 ` [PATCH 3/3] perf tools: Make 'struct map_shared' truly shared Jiri Olsa
2019-10-14 3:10 ` Andi Kleen
2019-10-14 8:48 ` Jiri Olsa
2019-10-14 19:20 ` Jiri Olsa
2019-10-14 19:46 ` Andi Kleen
2019-10-14 20:40 ` Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191013151427.11941-2-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mpetlan@redhat.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).