Fix perf-tool crashes when kvm guest is running
v2 cover Fix perf-tool crashes when kvm guest is running
Hi,
here are the fixes I promised. These patches should fix the crashes David and Jason have seen by making sure no sample is processed when ther is no valid machine object for it. The second patch also changes the perf_guest default back to false.
v1->v2:
* Introduced counter for unprocessable samples
* Added ui warnings when unprocessable samples are found
Regards,
Joerg
PATCH v2 1/2 perf-tool: 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.
--- tools/perf/builtin-top.c | 6 ++++++ tools/perf/util/hist.h | 1 + tools/perf/util/session.c | 10 ++++++++++ 3 files changed, 17 insertions(+), 0 deletions(-)
tools/perf/builtin-top.c +6 -0
@@ -668,6 +668,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++;
tools/perf/util/hist.h +1 -0
@@ -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 {
tools/perf/util/session.c +10 -0
@@ -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))
Signature · 1 line
1.7.5.4
[tip:perf/core] perf top: Don' t process samples with no valid machine object
Commit-ID: 0c095715b388d19d7a0b7e8eaceeceb018f5b3d1 Gitweb: http://git.kernel.org/tip/0c095715b388d19d7a0b7e8eaceeceb018f5b3d1 Author: Joerg Roedel <[email protected]> AuthorDate: Fri, 10 Feb 2012 18:05:04 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 13 Feb 2012 22:55:58 -0200
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.
--- tools/perf/builtin-top.c | 6 ++++++ tools/perf/util/hist.h | 1 + tools/perf/util/session.c | 10 ++++++++++ 3 files changed, 17 insertions(+), 0 deletions(-)
tools/perf/builtin-top.c +6 -0
@@ -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++;
tools/perf/util/hist.h +1 -0
@@ -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 {
tools/perf/util/session.c +10 -0
@@ -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))
PATCH v2 2/2 perf-tool: Change perf_guest default back to false
In reply to Joerg RoedelSetting perf_guest to true by default makes no sense because the perf subcommands can not setup guest symbol information and thus not process and guest samples. The only exception is perf-kvm which changes the perf_guest value on its own. So change the default for perf_guest back to false.
--- tools/perf/util/util.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/util.c +1 -1
@@ -6,7 +6,7 @@* XXX We need to find a better place for these things... */ bool perf_host = true; -bool perf_guest = true; +bool perf_guest = false;void event_attr_init (struct perf_event_attr *attr) {
Signature · 1 line
1.7.5.4
[tip:perf/core] perf tools: Change perf_guest default back to false
Commit-ID: c4a7dca92bbb9881a5d678720f1d0c2153499749 Gitweb: http://git.kernel.org/tip/c4a7dca92bbb9881a5d678720f1d0c2153499749 Author: Joerg Roedel <[email protected]> AuthorDate: Fri, 10 Feb 2012 18:05:05 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 13 Feb 2012 23:14:44 -0200
perf tools: Change perf_guest default back to false
Setting perf_guest to true by default makes no sense because the perf subcommands can not setup guest symbol information and thus not process and guest samples. The only exception is perf-kvm which changes the perf_guest value on its own. So change the default for perf_guest back to false.
--- tools/perf/util/util.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/util.c +1 -1
@@ -6,7 +6,7 @@* XXX We need to find a better place for these things... */ bool perf_host = true; -bool perf_guest = true; +bool perf_guest = false;void event_attr_init (struct perf_event_attr *attr) {
[tip:perf/core] perf tools: Change perf_guest default back to false
In reply to Joerg RoedelCommit-ID: 8f54ed4a2d8cf001456d3779bdb33985a050bf03 Gitweb: http://git.kernel.org/tip/8f54ed4a2d8cf001456d3779bdb33985a050bf03 Author: Joerg Roedel <[email protected]> AuthorDate: Fri, 10 Feb 2012 18:05:05 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Sat, 3 Mar 2012 12:13:41 -0300
perf tools: Change perf_guest default back to false
Setting perf_guest to true by default makes no sense because the perf subcommands can not setup guest symbol information and thus not process and guest samples. The only exception is perf-kvm which changes the perf_guest value on its own. So change the default for perf_guest back to false.
--- tools/perf/util/util.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/util.c +1 -1
@@ -6,7 +6,7 @@* XXX We need to find a better place for these things... */ bool perf_host = true; -bool perf_guest = true; +bool perf_guest = false;void event_attr_init (struct perf_event_attr *attr) {