diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2012-02-10 12:05:04 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-02-13 19:55:58 -0500 |
commit | 0c095715b388d19d7a0b7e8eaceeceb018f5b3d1 (patch) | |
tree | 5938972af1770fdd2c26866bebaf44e4e082948c | |
parent | b52956c961be3a04182ae7b776623531601e0fb7 (diff) |
perf top: Don't process samples with no valid machine object
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>
-rw-r--r-- | tools/perf/builtin-top.c | 6 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 1 | ||||
-rw-r--r-- | tools/perf/util/session.c | 10 |
3 files changed, 17 insertions, 0 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 94d55cb2048c..5a88c0dadf15 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -677,6 +677,12 @@ static void perf_event__process_sample(struct perf_tool *tool, | |||
677 | return; | 677 | return; |
678 | } | 678 | } |
679 | 679 | ||
680 | if (!machine) { | ||
681 | pr_err("%u unprocessable samples recorded.", | ||
682 | top->session->hists.stats.nr_unprocessable_samples++); | ||
683 | return; | ||
684 | } | ||
685 | |||
680 | if (event->header.misc & PERF_RECORD_MISC_EXACT_IP) | 686 | if (event->header.misc & PERF_RECORD_MISC_EXACT_IP) |
681 | top->exact_samples++; | 687 | top->exact_samples++; |
682 | 688 | ||
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 0d486135d10f..48e5acd1e862 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -32,6 +32,7 @@ struct events_stats { | |||
32 | u32 nr_unknown_events; | 32 | u32 nr_unknown_events; |
33 | u32 nr_invalid_chains; | 33 | u32 nr_invalid_chains; |
34 | u32 nr_unknown_id; | 34 | u32 nr_unknown_id; |
35 | u32 nr_unprocessable_samples; | ||
35 | }; | 36 | }; |
36 | 37 | ||
37 | enum hist_column { | 38 | enum hist_column { |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 552c1c50eea1..9f833cf9c6a9 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -796,6 +796,10 @@ static int perf_session_deliver_event(struct perf_session *session, | |||
796 | ++session->hists.stats.nr_unknown_id; | 796 | ++session->hists.stats.nr_unknown_id; |
797 | return -1; | 797 | return -1; |
798 | } | 798 | } |
799 | if (machine == NULL) { | ||
800 | ++session->hists.stats.nr_unprocessable_samples; | ||
801 | return -1; | ||
802 | } | ||
799 | return tool->sample(tool, event, sample, evsel, machine); | 803 | return tool->sample(tool, event, sample, evsel, machine); |
800 | case PERF_RECORD_MMAP: | 804 | case PERF_RECORD_MMAP: |
801 | return tool->mmap(tool, event, sample, machine); | 805 | return tool->mmap(tool, event, sample, machine); |
@@ -964,6 +968,12 @@ static void perf_session__warn_about_errors(const struct perf_session *session, | |||
964 | session->hists.stats.nr_invalid_chains, | 968 | session->hists.stats.nr_invalid_chains, |
965 | session->hists.stats.nr_events[PERF_RECORD_SAMPLE]); | 969 | session->hists.stats.nr_events[PERF_RECORD_SAMPLE]); |
966 | } | 970 | } |
971 | |||
972 | if (session->hists.stats.nr_unprocessable_samples != 0) { | ||
973 | ui__warning("%u unprocessable samples recorded.\n" | ||
974 | "Do you have a KVM guest running and not using 'perf kvm'?\n", | ||
975 | session->hists.stats.nr_unprocessable_samples); | ||
976 | } | ||
967 | } | 977 | } |
968 | 978 | ||
969 | #define session_done() (*(volatile int *)(&session_done)) | 979 | #define session_done() (*(volatile int *)(&session_done)) |