summaryrefslogtreecommitdiff
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-kmem.c5
-rw-r--r--tools/perf/builtin-record.c5
-rw-r--r--tools/perf/builtin-top.c5
-rw-r--r--tools/perf/util/session.c13
4 files changed, 11 insertions, 17 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 7323d9dfbce8..38b8ca900eda 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -491,11 +491,6 @@ static int __cmd_kmem(void)
if (!perf_session__has_traces(session, "kmem record"))
goto out_delete;
- if (perf_session__create_kernel_maps(session) < 0) {
- pr_err("Problems creating kernel maps\n");
- return -1;
- }
-
setup_pager();
err = perf_session__process_events(session, &event_ops);
if (err != 0)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 7bb9ca1b30fa..90345223908c 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -477,11 +477,6 @@ static int __cmd_record(int argc, const char **argv)
return -1;
}
- if (perf_session__create_kernel_maps(session) < 0) {
- pr_err("Problems creating kernel maps\n");
- return -1;
- }
-
if (!file_new) {
err = perf_header__read(&session->header, output);
if (err < 0)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 78f9c4576a0c..1fc018e048e1 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1191,11 +1191,6 @@ static int __cmd_top(void)
if (session == NULL)
return -ENOMEM;
- if (perf_session__create_kernel_maps(session) < 0) {
- pr_err("Problems creating kernel maps\n");
- return -1;
- }
-
if (target_pid != -1)
event__synthesize_thread(target_pid, event__process, session);
else
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 1951e330377c..8e7c1896eaa2 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -70,8 +70,17 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc
self->unknown_events = 0;
map_groups__init(&self->kmaps);
- if (mode == O_RDONLY && perf_session__open(self, force) < 0)
- goto out_delete;
+ if (mode == O_RDONLY) {
+ if (perf_session__open(self, force) < 0)
+ goto out_delete;
+ } else if (mode == O_WRONLY) {
+ /*
+ * In O_RDONLY mode this will be performed when reading the
+ * kernel MMAP event, in event__process_mmap().
+ */
+ if (perf_session__create_kernel_maps(self) < 0)
+ goto out_delete;
+ }
self->sample_type = perf_header__sample_type(&self->header);
out: