From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752170AbbH1GhM (ORCPT ); Fri, 28 Aug 2015 02:37:12 -0400 Received: from terminus.zytor.com ([198.137.202.10]:54601 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752106AbbH1GhK (ORCPT ); Fri, 28 Aug 2015 02:37:10 -0400 Date: Thu, 27 Aug 2015 23:36:53 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: mingo@kernel.org, namhyung@kernel.org, eranian@google.com, bp@suse.de, linux-kernel@vger.kernel.org, adrian.hunter@intel.com, jolsa@redhat.com, hpa@zytor.com, fweisbec@gmail.com, acme@redhat.com, dsahern@gmail.com, tglx@linutronix.de Reply-To: namhyung@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org, eranian@google.com, bp@suse.de, hpa@zytor.com, jolsa@redhat.com, adrian.hunter@intel.com, tglx@linutronix.de, dsahern@gmail.com, fweisbec@gmail.com, acme@redhat.com To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf annotate: Reset the dso find_symbol cache when removing symbols Git-Commit-ID: c0b4dffbc529244d3e4e3bd392f2bffa2d8531a7 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: c0b4dffbc529244d3e4e3bd392f2bffa2d8531a7 Gitweb: http://git.kernel.org/tip/c0b4dffbc529244d3e4e3bd392f2bffa2d8531a7 Author: Arnaldo Carvalho de Melo AuthorDate: Mon, 24 Aug 2015 13:33:14 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 24 Aug 2015 13:33:14 -0300 perf annotate: Reset the dso find_symbol cache when removing symbols The 'annotate' tool does some filtering in the entries in a DSO but forgot to reset the cache done in dso__find_symbol(), cauxing a SEGV: [root@zoo ~]# perf annotate netlink_poll perf: Segmentation fault -------- backtrace -------- perf[0x526ceb] /lib64/libc.so.6(+0x34960)[0x7faedfbe0960] perf(rb_erase+0x223)[0x499d63] perf[0x4213e9] perf[0x4bc123] perf[0x4bc621] perf[0x4bf26b] perf[0x4bc855] perf(perf_session__process_events+0x340)[0x4bddc0] perf(cmd_annotate+0x6bb)[0x421b5b] perf[0x479063] perf(main+0x60a)[0x42098a] /lib64/libc.so.6(__libc_start_main+0xf0)[0x7faedfbcbfe0] perf[0x420aa9] [0x0] [root@zoo ~]# Fix it by reseting the find cache when removing symbols. Cc: Adrian Hunter Cc: Borislav Petkov Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Stephane Eranian Fixes: b685ac22b436 ("perf symbols: Add front end cache for DSO symbol lookup") Link: http://lkml.kernel.org/n/tip-b2y9x46y0t8yem1ive41zqyp@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-annotate.c | 1 + tools/perf/util/dso.h | 2 ++ tools/perf/util/symbol.c | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index a32a64e..8edc205 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -67,6 +67,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel, rb_erase(&al->sym->rb_node, &al->map->dso->symbols[al->map->type]); symbol__delete(al->sym); + dso__reset_find_symbol_cache(al->map->dso); } return 0; } diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index c73276d..fc8db9c 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -324,6 +324,8 @@ struct dso *__dsos__findnew(struct dsos *dsos, const char *name); struct dso *dsos__findnew(struct dsos *dsos, const char *name); bool __dsos__read_build_ids(struct list_head *head, bool with_hits); +void dso__reset_find_symbol_cache(struct dso *dso); + size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp, bool (skip)(struct dso *dso, int parm), int parm); size_t __dsos__fprintf(struct list_head *head, FILE *fp); diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 42e98ab..46ae053 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -441,6 +441,16 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols, return &s->sym; } +void dso__reset_find_symbol_cache(struct dso *dso) +{ + enum map_type type; + + for (type = MAP__FUNCTION; type <= MAP__VARIABLE; ++type) { + dso->last_find_result[type].addr = 0; + dso->last_find_result[type].symbol = NULL; + } +} + struct symbol *dso__find_symbol(struct dso *dso, enum map_type type, u64 addr) {