Fix perf-tool crashes when kvm guest is running
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.
Regards,
Joerg
PATCH 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.
--- tools/perf/builtin-top.c | 2 +- tools/perf/util/session.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-top.c +1 -1
@@ -805,7 +805,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) } -if (event->header.type ==PERF_RECORD_SAMPLE ) { +if (event->header.type ==PERF_RECORD_SAMPLE && machine !=NULL ) {perf_event__process_sample (&top->tool, event, evsel, &sample, machine); }else if (event->header.type <PERF_RECORD_MAX ) {
tools/perf/util/session.c +1 -1
@@ -792,7 +792,7 @@ static int perf_session_deliver_event(struct perf_session *session,switch (event->header.type) {case PERF_RECORD_SAMPLE :dump_sample (session, event, sample); -if (evsel ==NULL ) { +if (evsel ==NULL || machine ==NULL ) { ++session->hists.stats.nr_unknown_id;return -1 ; }
Signature · 1 line
1.7.5.4
Re: [PATCH 1/2] perf-tool: Don't process samples with no valid machine object
Em Thu, Feb 09, 2012 at 05:07:38PM +0100, Joerg Roedel escreveu:
Quoted 15 lines
The perf sample processing code relies on a valid machine object. Make sure that this path is only entered when such a object exists.
Signed-off-by Joerg Roedel <[email protected]>--- tools/perf/builtin-top.c | 2 +- tools/perf/util/session.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/perf/builtin-top.c +0
-0
tools/perf/builtin-top.c static void perf_top__mmap_read_idx(struct perf_top *top, int idx) · line 808
Quoted 5 lines
tools/perf/builtin-top.c +1
-1@@ -805,7 +805,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) } -if (event->header.type ==PERF_RECORD_SAMPLE ) { +if (event->header.type ==PERF_RECORD_SAMPLE && machine !=NULL ) {
Shouldn't we warn the user, even if just once, on the status (last line on the screen) line?
Quoted 19 lines
tools/perf/builtin-top.c +0
-0perf_event__process_sample (&top->tool, event, evsel, &sample, machine); }else if (event->header.type <PERF_RECORD_MAX ) {tools/perf/util/session.c +1
-1@@ -792,7 +792,7 @@ static int perf_session_deliver_event(struct perf_session *session,switch (event->header.type) {case PERF_RECORD_SAMPLE :dump_sample (session, event, sample); -if (evsel ==NULL ) { +if (evsel ==NULL || machine ==NULL ) { ++session->hists.stats.nr_unknown_id;return -1 ; }Signature · 1 line
1.7.5.4
Re: [PATCH 1/2] perf-tool: Don't process samples with no valid machine object
Quoted 6 lines · Arnaldo Carvalho de Melo
Em Thu, Feb 09, 2012 at 05:07:38PM +0100, Joerg Roedel escreveu:
tools/perf/builtin-top.c static void perf_top__mmap_read_idx(struct perf_top *top, int idx) · line 808
Quoted 2 lines
tools/perf/builtin-top.c +1
-1-if (event->header.type ==PERF_RECORD_SAMPLE ) { +if (event->header.type ==PERF_RECORD_SAMPLE && machine !=NULL ) {Shouldn't we warn the user, even if just once, on the status (last line on the screen) line?
Probably yes, what would be a good message? I guess something like
"no machine object for sample"
is not helpful to the user. Maybe something like
"Unresolvable sample(s) recorded"?
Or something completly different?
Joerg
Signature · 5 lines
AMD Operating System Research Center Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach General Managers: Alberto Bozzo Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
Re: [PATCH 1/2] perf-tool: Don't process samples with no valid machine object
Em Thu, Feb 09, 2012 at 06:13:34PM +0100, Joerg Roedel escreveu:
Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 6 lines
Em Thu, Feb 09, 2012 at 05:07:38PM +0100, Joerg Roedel escreveu:
tools/perf/builtin-top.c static void perf_top__mmap_read_idx(struct perf_top *top, int idx) · line 808
Quoted 2 lines
tools/perf/builtin-top.c +1
-1-if (event->header.type ==PERF_RECORD_SAMPLE ) { +if (event->header.type ==PERF_RECORD_SAMPLE && machine !=NULL ) {Shouldn't we warn the user, even if just once, on the status (last line on the screen) line?
Probably yes, what would be a good message? I guess something like
Quoted 7 lines
"no machine object for sample"
is not helpful to the user. Maybe something like
"Unresolvable sample(s) recorded"?
Or something completly different?
This is not completely standardized or harminized across the sources, but we have things like:
if (verbose)
error("Failed to resolve callchain. Skipping\n");---
if (perf_event__preprocess_sample(event, machine, &al, sample,
NULL) < 0) {
error("problem processing %d event, skipping it.\n",
event->header.type);
return;
}---
if (!ip_callchain__valid(sample->callchain, event)) {
pr_debug("call-chain problem with event, skipping it.\n");
++session->hists.stats.nr_invalid_chains;---
What has been done more recently is like the above, account the
number of different problems and then, at the end do like:
if (session->hists.stats.nr_unknown_id != 0) {
ui__warning("%u samples with id not present in the header\n",
session->hists.stats.nr_unknown_id);
}
But this is for perf report or other tools that process allevents and then provide some post processed results, just before presenting these results.
I guess we could do that too for 'perf top' like tools, that
continuously show results while collecting more. Perhaps call ui__warning() if some threshold happens, i.e. if way too many errors of some kind are happening and then at the end provide a summary of errors found.
- Arnaldo
PATCH 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