Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752237AbbKPK7M (ORCPT ); Mon, 16 Nov 2015 05:59:12 -0500 Received: from terminus.zytor.com ([198.137.202.10]:51883 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751163AbbKPK7K (ORCPT ); Mon, 16 Nov 2015 05:59:10 -0500 Date: Mon, 16 Nov 2015 02:58:43 -0800 From: tip-bot for Adrian Hunter Message-ID: Cc: tglx@linutronix.de, namhyung@kernel.org, acme@redhat.com, hpa@zytor.com, masami.hiramatsu.pt@hitachi.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org, mingo@kernel.org, adrian.hunter@intel.com, lizefan@huawei.com, jolsa@kernel.org Reply-To: tglx@linutronix.de, namhyung@kernel.org, hpa@zytor.com, acme@redhat.com, masami.hiramatsu.pt@hitachi.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org, mingo@kernel.org, jolsa@kernel.org, lizefan@huawei.com, adrian.hunter@intel.com In-Reply-To: <563CB241.2090701@intel.com> References: <563CB241.2090701@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf symbols: Rebuild rbtree when adjusting symbols for kcore Git-Commit-ID: 866548dd6e22c3795ae5146a9746a5cf659698f1 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 Content-Length: 3684 Lines: 107 Commit-ID: 866548dd6e22c3795ae5146a9746a5cf659698f1 Gitweb: http://git.kernel.org/tip/866548dd6e22c3795ae5146a9746a5cf659698f1 Author: Adrian Hunter AuthorDate: Fri, 6 Nov 2015 15:59:29 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 12 Nov 2015 18:58:17 -0300 perf symbols: Rebuild rbtree when adjusting symbols for kcore Normally symbols are read from the DSO and adjusted, if need be, so that the symbol start matches the file offset in the DSO file (we want the file offset because that is what we know from MMAP events). That is done by dso__load_sym() which inserts the symbols *after* adjusting them. In the case of kcore, the symbols have been read from kallsyms and the symbol start is the memory address. The symbols have to be adjusted to match the kcore file offsets. dso__split_kallsyms_for_kcore() does that, but now the adjustment is being done *after* the symbols have been inserted. It appears dso__split_kallsyms_for_kcore() was assuming that changing the symbol start would not change the order in the rbtree - which is, of course, not guaranteed. Signed-off-by: Adrian Hunter Tested-by: Wang Nan Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/563CB241.2090701@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index b4cc766..09343a8 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -654,19 +654,24 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map, struct map_groups *kmaps = map__kmaps(map); struct map *curr_map; struct symbol *pos; - int count = 0, moved = 0; + int count = 0; + struct rb_root old_root = dso->symbols[map->type]; struct rb_root *root = &dso->symbols[map->type]; struct rb_node *next = rb_first(root); if (!kmaps) return -1; + *root = RB_ROOT; + while (next) { char *module; pos = rb_entry(next, struct symbol, rb_node); next = rb_next(&pos->rb_node); + rb_erase_init(&pos->rb_node, &old_root); + module = strchr(pos->name, '\t'); if (module) *module = '\0'; @@ -674,28 +679,21 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map, curr_map = map_groups__find(kmaps, map->type, pos->start); if (!curr_map || (filter && filter(curr_map, pos))) { - rb_erase_init(&pos->rb_node, root); symbol__delete(pos); - } else { - pos->start -= curr_map->start - curr_map->pgoff; - if (pos->end) - pos->end -= curr_map->start - curr_map->pgoff; - if (curr_map->dso != map->dso) { - rb_erase_init(&pos->rb_node, root); - symbols__insert( - &curr_map->dso->symbols[curr_map->type], - pos); - ++moved; - } else { - ++count; - } + continue; } + + pos->start -= curr_map->start - curr_map->pgoff; + if (pos->end) + pos->end -= curr_map->start - curr_map->pgoff; + symbols__insert(&curr_map->dso->symbols[curr_map->type], pos); + ++count; } /* Symbols have been adjusted */ dso->adjust_symbols = 1; - return count + moved; + return count; } /* -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/