From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
Jiri Olsa <jolsa@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Thomas Gleixner <tglx@linutronix.de>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 06/12] perf tools: Insert split maps correctly into origin group
Date: Thu, 5 Nov 2015 13:02:16 -0300 [thread overview]
Message-ID: <1446739342-29279-7-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1446739342-29279-1-git-send-email-acme@kernel.org>
From: Jiri Olsa <jolsa@redhat.com>
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 <symbol_filter>, map=<opti
#5 map__find_symbol (map=0x1abb7a0, addr=40188, filter=0x4393c0 <symbol_filter
...
Adding __map_groups__insert function to add map into groups together
with 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 <markus@trippelsdorf.de>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
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 <acme@redhat.com>
---
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 4e38c396a897..afc6b56cf749 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);
}
--
2.1.0
next prev parent reply other threads:[~2015-11-05 16:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-05 16:02 [GIT PULL 00/12] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-11-05 16:02 ` [PATCH 01/12] perf test: Keep test result clean if '-v' not set Arnaldo Carvalho de Melo
2015-11-05 16:02 ` [PATCH 02/12] perf bpf: Mute libbpf when " Arnaldo Carvalho de Melo
2015-11-05 16:02 ` [PATCH 03/12] tools lib bpf: Fix compiler warning on CentOS 6 Arnaldo Carvalho de Melo
2015-11-05 16:02 ` [PATCH 04/12] perf stat: Move sw clock metrics printout to stat-shadow Arnaldo Carvalho de Melo
2015-11-05 16:02 ` [PATCH 05/12] perf stat: Use common printout function to avoid duplicated code Arnaldo Carvalho de Melo
2015-11-05 16:02 ` Arnaldo Carvalho de Melo [this message]
2015-11-05 16:02 ` [PATCH 07/12] perf tools: Allow shuffling the build tests Arnaldo Carvalho de Melo
2015-11-05 16:02 ` [PATCH 08/12] perf llvm: Pass available CPU number to clang compiler Arnaldo Carvalho de Melo
2015-11-05 16:02 ` [PATCH 09/12] perf llvm: Pass LINUX_VERSION_CODE to BPF program when compiling Arnaldo Carvalho de Melo
2015-11-05 16:02 ` [PATCH 10/12] tools lib bpf: Change FEATURE-DUMP to FEATURE-DUMP.libbpf Arnaldo Carvalho de Melo
2015-11-05 16:02 ` [PATCH 11/12] perf trace: Fix documentation for -i Arnaldo Carvalho de Melo
2015-11-05 16:02 ` [PATCH 12/12] perf tools: Fix find_perf_probe_point_from_map() which incorrectly returns success 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=1446739342-29279-7-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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).