[PATCH 06/12] perf tools: Do not erase uncovered maps by kcore

Jiri Olsa
2019-04-16T16:01:57Z

Maps in kcore do not cover bpf maps, so we can't just
remove everything. Keeping all kernel maps, which are
not covered by kcore maps.

Link: http://lkml.kernel.org/n/tip-9eytka8wofp0a047ul6lmejk@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/symbol.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 5cbad55cd99d..96738a7a8c14 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1166,6 +1166,18 @@ static int kcore_mapfn(u64 start, u64 len, u64 pgoff, void *data)
return 0;
}

+static bool in_kcore(struct kcore_mapfn_data *md, struct map *map)
+{
+ struct map *iter;
+
+ list_for_each_entry(iter, &md->maps, node) {
+ if ((map->start >= iter->start) && (map->start < iter->end))
+ return true;
+ }
+
+ return false;
+}
+
static int dso__load_kcore(struct dso *dso, struct map *map,
const char *kallsyms_filename)
{
@@ -1222,7 +1234,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
while (old_map) {
struct map *next = map_groups__next(old_map);

- if (old_map != map)
+ if (old_map != map && !in_kcore(&md, old_map))
map_groups__remove(kmaps, old_map);
old_map = next;
}
--
2.17.2