Skip to contentSkip to conversation

perf tools: Try to lookup kernel module map before creating one

tip:perf/core tip-bot for Jiri Olsa 1 participant 1 message Mar 24, 2015 perf events

lore
Share & tools
lore

tip-bot for Jiri Olsa

author merge bot
#0 lore raw
Commit-ID:  bc84f464862489e687c98dea1a8ff20dc4413f93
Gitweb:     http://git.kernel.org/tip/bc84f464862489e687c98dea1a8ff20dc4413f93
Author:     Jiri Olsa <[email protected]>
AuthorDate: Tue, 17 Feb 2015 17:31:18 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 23 Mar 2015 12:46:51 -0300

perf tools: Try to lookup kernel module map before creating one

Currently we assume machine__new_module is called only once for each module so we create its map&dso unconditionally.

However it's possible that it's called multiple times for same module. Like for perf record:

1) via machine__create_module during machine init
2) via kernel MMAP event processing

Trying to lookup kernel module map before creating one.

---
 tools/perf/util/machine.c | 5 +++++
 1 file changed, 5 insertions(+)
tools/perf/util/machine.c +5 -0
index 1de5438..e335330 100644
@@ -498,6 +498,11 @@ struct map *machine__new_module(struct machine *machine, u64 start,
 	if (kmod_path__parse_name(&m, filename))
 		return NULL;
 
+	map = map_groups__find_by_name(&machine->kmaps, MAP__FUNCTION,
+				       m.name);
+	if (map)
+		goto out;
+
 	dso = machine__module_dso(machine, &m, filename);
 	if (dso == NULL)
 		goto out;