From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
Anton Blanchard <anton@au1.ibm.com>, Jiri Olsa <jolsa@redhat.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 01/32] perf tools powerpc: Cache the DWARF debug info
Date: Tue, 28 Oct 2014 11:31:55 -0200 [thread overview]
Message-ID: <1414503146-22789-2-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1414503146-22789-1-git-send-email-acme@kernel.org>
From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cache the DWARF debug info for DSO so we don't have to rebuild it for each
address in the DSO.
Note that dso__new() uses calloc() so don't need to set dso->dwfl to NULL.
$ /tmp/perf.orig --version
perf version 3.18.rc1.gc2661b8
$ /tmp/perf.new --version
perf version 3.18.rc1.g402d62
$ perf stat -e cycles,instructions /tmp/perf.orig report -g > orig
Performance counter stats for '/tmp/perf.orig report -g':
6,428,177,183 cycles # 0.000 GHz
4,176,288,391 instructions # 0.65 insns per cycle
1.840666132 seconds time elapsed
$ perf stat -e cycles,instructions /tmp/perf.new report -g > new
Performance counter stats for '/tmp/perf.new report -g':
305,773,142 cycles # 0.000 GHz
276,048,272 instructions # 0.90 insns per cycle
0.087693543 seconds time elapsed
$ diff orig new
$
Changelog[v2]:
[Arnaldo Carvalho] Cache in existing global objects rather than create
new static/globals in functions.
Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Anton Blanchard <anton@au1.ibm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20141022000958.GB2228@us.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/arch/powerpc/util/skip-callchain-idx.c | 33 +++++++++++++++--------
tools/perf/util/dso.h | 1 +
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
index d73ef8bb08c7..9892b0f0bec4 100644
--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
+++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
@@ -145,7 +145,7 @@ static Dwarf_Frame *get_dwarf_frame(Dwfl_Module *mod, Dwarf_Addr pc)
* yet used)
* -1 in case of errors
*/
-static int check_return_addr(const char *exec_file, Dwarf_Addr pc)
+static int check_return_addr(struct dso *dso, Dwarf_Addr pc)
{
int rc = -1;
Dwfl *dwfl;
@@ -156,15 +156,27 @@ static int check_return_addr(const char *exec_file, Dwarf_Addr pc)
Dwarf_Addr end = pc;
bool signalp;
- dwfl = dwfl_begin(&offline_callbacks);
- if (!dwfl) {
- pr_debug("dwfl_begin() failed: %s\n", dwarf_errmsg(-1));
- return -1;
- }
+ dwfl = dso->dwfl;
- if (dwfl_report_offline(dwfl, "", exec_file, -1) == NULL) {
- pr_debug("dwfl_report_offline() failed %s\n", dwarf_errmsg(-1));
- goto out;
+ if (!dwfl) {
+ dwfl = dwfl_begin(&offline_callbacks);
+ if (!dwfl) {
+ pr_debug("dwfl_begin() failed: %s\n", dwarf_errmsg(-1));
+ return -1;
+ }
+
+ if (dwfl_report_offline(dwfl, "", dso->long_name, -1) == NULL) {
+ pr_debug("dwfl_report_offline() failed %s\n",
+ dwarf_errmsg(-1));
+ /*
+ * We normally cache the DWARF debug info and never
+ * call dwfl_end(). But to prevent fd leak, free in
+ * case of error.
+ */
+ dwfl_end(dwfl);
+ goto out;
+ }
+ dso->dwfl = dwfl;
}
mod = dwfl_addrmodule(dwfl, pc);
@@ -194,7 +206,6 @@ static int check_return_addr(const char *exec_file, Dwarf_Addr pc)
rc = check_return_reg(ra_regno, frame);
out:
- dwfl_end(dwfl);
return rc;
}
@@ -246,7 +257,7 @@ int arch_skip_callchain_idx(struct machine *machine, struct thread *thread,
return skip_slot;
}
- rc = check_return_addr(dso->long_name, ip);
+ rc = check_return_addr(dso, ip);
pr_debug("DSO %s, nr %" PRIx64 ", ip 0x%" PRIx64 "rc %d\n",
dso->long_name, chain->nr, ip, rc);
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index acb651acc7fd..3c9b391493f9 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -127,6 +127,7 @@ struct dso {
const char *long_name;
u16 long_name_len;
u16 short_name_len;
+ void *dwfl; /* DWARF debug info */
/* dso data file */
struct {
--
1.9.3
next prev parent reply other threads:[~2014-10-28 13:32 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-28 13:31 [GIT PULL 00/32] perf/core improvements and fixes Arnaldo Carvalho de Melo
2014-10-28 13:31 ` Arnaldo Carvalho de Melo [this message]
2014-10-29 6:39 ` [PATCH 01/32] perf tools powerpc: Cache the DWARF debug info Namhyung Kim
2014-10-29 21:26 ` Sukadev Bhattiprolu
2014-10-31 3:10 ` Namhyung Kim
2014-10-28 13:31 ` [PATCH 02/32] perf tools: Set thread->mg.machine in all places Arnaldo Carvalho de Melo
2014-10-28 13:31 ` [PATCH 03/32] perf tools: A thread's machine can be found via thread->mg->machine Arnaldo Carvalho de Melo
2014-10-28 13:31 ` [PATCH 04/32] perf thread: Adopt resolve_callchain method from machine Arnaldo Carvalho de Melo
2014-10-28 13:31 ` [PATCH 05/32] perf callchains: Use thread->mg->machine Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 06/32] perf tests: Remove misplaced __maybe_unused Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 07/32] perf tests: Use thread->mg->machine Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 08/32] perf tools: Add PARSE_OPT_DISABLED flag Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 09/32] perf tools: Export usage string and option table of perf record Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 10/32] perf kvm: Print kvm specific --help output Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 11/32] perf tools: Add support for exclusive option Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 12/32] perf probe: Use PARSE_OPT_EXCLUSIVE flag Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 13/32] perf callchain: Use global caching provided by libunwind Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 14/32] perf tools: Ensure return negative value when write header error Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 15/32] perf pmu: Let pmu's with no events show up on perf list Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 16/32] perf tools: Build programs to copy 32-bit compatibility Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 17/32] perf tools: Add support for 32-bit compatibility VDSOs Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 18/32] perf tools: Do not attempt to run perf-read-vdso32 if it wasn't built Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 19/32] perf tools: Make CPUINFO_PROC an array to support different kernel versions Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 20/32] perf pmu: Add proper error handling to print_pmu_events() Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 21/32] perf tools: Fix report -F abort for data without branch info Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 22/32] perf tools: Fix report -F in_tx " Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 23/32] perf tools: Fix report -F mispredict " Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 24/32] perf tools: Fix report -F symbol_to " Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 25/32] perf tools: Fix report -F symbol_from " Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 26/32] perf tools: Fix report -F dso_to " Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 27/32] perf tools: Fix report -F dso_from " Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 28/32] perf tools: Add facility to export data in database-friendly way Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 29/32] perf scripting python: Extend interface to export data in a " Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 30/32] perf script: Add Python script to export to postgresql Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 31/32] perf probe: Trivial typo fix for --demangle Arnaldo Carvalho de Melo
2014-10-28 13:32 ` [PATCH 32/32] perf probe: Add --quiet option to suppress output result message Arnaldo Carvalho de Melo
2014-10-29 9:11 ` [GIT PULL 00/32] perf/core improvements and fixes Ingo Molnar
2014-10-29 12:58 ` Arnaldo Carvalho de Melo
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=1414503146-22789-2-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=anton@au1.ibm.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=sukadev@linux.vnet.ibm.com \
/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).