]> git.karo-electronics.de Git - linux-beck.git/commitdiff
perf top: Don't process samples with no valid machine object
authorJoerg Roedel <joerg.roedel@amd.com>
Fri, 10 Feb 2012 17:05:04 +0000 (18:05 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 14 Feb 2012 00:55:58 +0000 (22:55 -0200)
The perf sample processing code relies on a valid machine object. Make
sure that this path is only entered when such a object exists.

A counter for samples where no machine object exits is also introduced
to give the user a message about these samples.

Reported-by: David Ahern <dsahern@gmail.com>
Reported-by: Jason Wang <jasowang@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1328893505-4115-2-git-send-email-joerg.roedel@amd.com
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-top.c
tools/perf/util/hist.h
tools/perf/util/session.c

index 94d55cb2048c38896f6112a8582808aa7cc5d005..5a88c0dadf1554ba5ee453311a21a4410695949f 100644 (file)
@@ -677,6 +677,12 @@ static void perf_event__process_sample(struct perf_tool *tool,
                return;
        }
 
+       if (!machine) {
+               pr_err("%u unprocessable samples recorded.",
+                      top->session->hists.stats.nr_unprocessable_samples++);
+               return;
+       }
+
        if (event->header.misc & PERF_RECORD_MISC_EXACT_IP)
                top->exact_samples++;
 
index 0d486135d10fde0bc06ec5b38cf5729dd7e0356b..48e5acd1e862f70c0f74a6a4dc53a2dc1246fd06 100644 (file)
@@ -32,6 +32,7 @@ struct events_stats {
        u32 nr_unknown_events;
        u32 nr_invalid_chains;
        u32 nr_unknown_id;
+       u32 nr_unprocessable_samples;
 };
 
 enum hist_column {
index 552c1c50eea19ddab61d322cff026f23170e1289..9f833cf9c6a9b9db2cf3874b33e7721110bb6591 100644 (file)
@@ -796,6 +796,10 @@ static int perf_session_deliver_event(struct perf_session *session,
                        ++session->hists.stats.nr_unknown_id;
                        return -1;
                }
+               if (machine == NULL) {
+                       ++session->hists.stats.nr_unprocessable_samples;
+                       return -1;
+               }
                return tool->sample(tool, event, sample, evsel, machine);
        case PERF_RECORD_MMAP:
                return tool->mmap(tool, event, sample, machine);
@@ -964,6 +968,12 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
                            session->hists.stats.nr_invalid_chains,
                            session->hists.stats.nr_events[PERF_RECORD_SAMPLE]);
        }
+
+       if (session->hists.stats.nr_unprocessable_samples != 0) {
+               ui__warning("%u unprocessable samples recorded.\n"
+                           "Do you have a KVM guest running and not using 'perf kvm'?\n",
+                           session->hists.stats.nr_unprocessable_samples);
+       }
 }
 
 #define session_done() (*(volatile int *)(&session_done))