Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754896AbbKHH3g (ORCPT ); Sun, 8 Nov 2015 02:29:36 -0500 Received: from terminus.zytor.com ([198.137.202.10]:45951 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754132AbbKHH3c (ORCPT ); Sun, 8 Nov 2015 02:29:32 -0500 Date: Sat, 7 Nov 2015 23:29:09 -0800 From: tip-bot for Jiri Olsa Message-ID: Cc: jolsa@kernel.org, a.p.zijlstra@chello.nl, markus@trippelsdorf.de, tglx@linutronix.de, mingo@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, jolsa@redhat.com, akpm@linux-foundation.org, acme@redhat.com Reply-To: acme@redhat.com, akpm@linux-foundation.org, hpa@zytor.com, jolsa@redhat.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, markus@trippelsdorf.de, a.p.zijlstra@chello.nl, jolsa@kernel.org In-Reply-To: <20151104140811.GA32664@krava.brq.redhat.com> References: <20151104140811.GA32664@krava.brq.redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf tools: Insert split maps correctly into origin group Git-Commit-ID: cb8382e05817a8104ea0edb63b8e37b8fbecd14c 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: 3458 Lines: 86 Commit-ID: cb8382e05817a8104ea0edb63b8e37b8fbecd14c Gitweb: http://git.kernel.org/tip/cb8382e05817a8104ea0edb63b8e37b8fbecd14c Author: Jiri Olsa AuthorDate: Wed, 4 Nov 2015 15:08:11 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 5 Nov 2015 11:39:38 -0300 perf tools: Insert split maps correctly into origin group When new maps are cloned out of split map they are added into origin map's group, but their groups pointer is not updated. This could lead to a segfault, because map->groups is expected to be always set as reported by Markus: __map__is_kernel (map=map@entry=0x1abb7a0) at util/map.c:238 238 return __machine__kernel_map(map->groups->machine, map->type) = (gdb) bt #0 __map__is_kernel (map=map@entry=0x1abb7a0) at util/map.c:238 #1 0x00000000004393e4 in symbol_filter (map=map@entry=0x1abb7a0, sym=sym@entry #2 0x00000000004fcd4d in dso__load_sym (dso=dso@entry=0x166dae0, map=map@entry #3 0x00000000004a64e0 in dso__load (dso=0x166dae0, map=map@entry=0x1abb7a0, fi #4 0x00000000004b941f in map__load (filter=0x4393c0 , map=groups pointer update. It takes no lock as opposed to existing map_groups__insert, as maps__fixup_overlappings(), where it is being called, already has the necessary lock held. Using __map_groups__insert to add new maps after map split. Reported-by: Markus Trippelsdorf Signed-off-by: Jiri Olsa Tested-by: Markus Trippelsdorf Cc: Andrew Morton Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20151104140811.GA32664@krava.brq.redhat.com Fixes: cfc5acd4c80b ("perf top: Filter symbols based on __map__is_kernel(map)") Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/map.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 4e38c39..afc6b56 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -644,6 +644,12 @@ size_t map_groups__fprintf(struct map_groups *mg, FILE *fp) return printed; } +static void __map_groups__insert(struct map_groups *mg, struct map *map) +{ + __maps__insert(&mg->maps[map->type], map); + map->groups = mg; +} + static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) { struct rb_root *root; @@ -682,7 +688,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp } before->end = map->start; - __maps__insert(maps, before); + __map_groups__insert(pos->groups, before); if (verbose >= 2) map__fprintf(before, fp); } @@ -696,7 +702,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp } after->start = map->end; - __maps__insert(maps, after); + __map_groups__insert(pos->groups, after); if (verbose >= 2) map__fprintf(after, fp); } -- 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/