From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932879AbbA3Sco (ORCPT ); Fri, 30 Jan 2015 13:32:44 -0500 Received: from terminus.zytor.com ([198.137.202.10]:35785 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756292AbbA3Scn (ORCPT ); Fri, 30 Jan 2015 13:32:43 -0500 Date: Fri, 30 Jan 2015 10:32:05 -0800 From: tip-bot for Namhyung Kim Message-ID: Cc: a.p.zijlstra@chello.nl, fweisbec@gmail.com, hpa@zytor.com, andi@firstfloor.org, dsahern@gmail.com, eranian@google.com, jolsa@redhat.com, adrian.hunter@intel.com, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, acme@redhat.com, namhyung@kernel.org Reply-To: fweisbec@gmail.com, a.p.zijlstra@chello.nl, hpa@zytor.com, dsahern@gmail.com, andi@firstfloor.org, eranian@google.com, jolsa@redhat.com, namhyung@kernel.org, acme@redhat.com, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org In-Reply-To: <1422518843-25818-41-git-send-email-namhyung@kernel.org> References: <1422518843-25818-41-git-send-email-namhyung@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf callchain: Cache eh/ debug frame offset for dwarf unwind Git-Commit-ID: f1f13af99a903ae873f5373e965508e0486c1c29 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f1f13af99a903ae873f5373e965508e0486c1c29 Gitweb: http://git.kernel.org/tip/f1f13af99a903ae873f5373e965508e0486c1c29 Author: Namhyung Kim AuthorDate: Thu, 29 Jan 2015 17:07:21 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 29 Jan 2015 16:20:42 -0300 perf callchain: Cache eh/debug frame offset for dwarf unwind When libunwind tries to resolve callchains it needs to know the offset of .eh_frame_hdr or .debug_frame to access the dso. Since it will always return the same result for a given DSO, just cache the result as an optimization. Signed-off-by: Namhyung Kim Cc: Adrian Hunter Cc: Andi Kleen Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1422518843-25818-41-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/dso.h | 1 + tools/perf/util/unwind-libunwind.c | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 3782c82..ced9284 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -139,6 +139,7 @@ struct dso { u32 status_seen; size_t file_size; struct list_head open_entry; + u64 frame_offset; } data; union { /* Tool specific area */ diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c index 6edf535..e3c40a5 100644 --- a/tools/perf/util/unwind-libunwind.c +++ b/tools/perf/util/unwind-libunwind.c @@ -266,14 +266,17 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, u64 *fde_count) { int ret = -EINVAL, fd; - u64 offset; + u64 offset = dso->data.frame_offset; - fd = dso__data_fd(dso, machine); - if (fd < 0) - return -EINVAL; + if (offset == 0) { + fd = dso__data_fd(dso, machine); + if (fd < 0) + return -EINVAL; - /* Check the .eh_frame section for unwinding info */ - offset = elf_section_offset(fd, ".eh_frame_hdr"); + /* Check the .eh_frame section for unwinding info */ + offset = elf_section_offset(fd, ".eh_frame_hdr"); + dso->data.frame_offset = offset; + } if (offset) ret = unwind_spec_ehframe(dso, machine, offset, @@ -287,14 +290,20 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, static int read_unwind_spec_debug_frame(struct dso *dso, struct machine *machine, u64 *offset) { - int fd = dso__data_fd(dso, machine); + int fd; + u64 ofs = dso->data.frame_offset; - if (fd < 0) - return -EINVAL; + if (ofs == 0) { + fd = dso__data_fd(dso, machine); + if (fd < 0) + return -EINVAL; - /* Check the .debug_frame section for unwinding info */ - *offset = elf_section_offset(fd, ".debug_frame"); + /* Check the .debug_frame section for unwinding info */ + ofs = elf_section_offset(fd, ".debug_frame"); + dso->data.frame_offset = ofs; + } + *offset = ofs; if (*offset) return 0;