perf session: Create kernel maps in the constructor
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 27 Jan 2010 23:05:52 +0000 (21:05 -0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 29 Jan 2010 08:20:58 +0000 (09:20 +0100)
Removing one extra step needed in the tools that need this,
fixing a bug in 'perf probe' where this was not being done.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1264633557-17597-4-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-kmem.c
tools/perf/builtin-record.c
tools/perf/builtin-top.c
tools/perf/util/session.c

index 7323d9dfbce87243c534e5621678370187c0e7b3..38b8ca900eda1522e769ec31dbf0c25c1ab3f283 100644 (file)
@@ -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)
index 7bb9ca1b30facc42652d8c62408b72cfd0dc9639..90345223908ca074984bae6714355533de34fda2 100644 (file)
@@ -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)
index 78f9c4576a0ca1dd1fc70872b1adff0e2a0d1da8..1fc018e048e1a543728a68346a409c90fac3004c 100644 (file)
@@ -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
index 1951e330377c099ecd284e9a0b99b650bbf7b7a2..8e7c1896eaa214f53bf485070e26c6d804a16c16 100644 (file)
@@ -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: