Skip to contentSkip to conversation

perf report: fix bug in raw smple parsing

PATCH In review Stephane Eranian 1 participant 2 messages Mar 17, 2012 – Mar 31, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf report: fix bug in raw smple parsing

In perf_event__parse_sample(), the array variable was not incremented by the amount of data used by the raw_data. That was okay until we added PERF_SAMPLE_BRANCH_STACK which depends on the array variable pointing to the beginning of the branch stack data. But that was not the case if branch stack was combined with raw mode sampling. That led to bogus branch stack addresses and count.

The bug would show up with:

$ perf record -R -b foo

This patch fixes the problem by correctly moving the array pointer forward for RAW samples.

---

tools/perf/util/evsel.c +2 -0
index f421f7c..9f35d92 100644
@@ -578,6 +578,8 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
 			return -EFAULT;
 
 		data->raw_data = (void *) pdata;
+
+		array = (void *)array + data->raw_size + sizeof(u32);
 	}
 
 	if (type & PERF_SAMPLE_BRANCH_STACK) {
#1 lore raw

[tip:perf/urgent] perf tools: Fix bug in raw sample parsing

Commit-ID:  fa30c964c0ac31a705a4f86072267a42343c4158
Gitweb:     http://git.kernel.org/tip/fa30c964c0ac31a705a4f86072267a42343c4158
Author:     Stephane Eranian <[email protected]>
AuthorDate: Sat, 17 Mar 2012 23:23:18 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 26 Mar 2012 15:36:03 -0300

perf tools: Fix bug in raw sample parsing

In perf_event__parse_sample(), the array variable was not incremented by the amount of data used by the raw_data.

That was okay until we added PERF_SAMPLE_BRANCH_STACK which depends on the array variable pointing to the beginning of the branch stack data.

But that was not the case if branch stack was combined with raw mode sampling. That led to bogus branch stack addresses and count.

The bug would show up with:

$ perf record -R -b foo

This patch fixes the problem by correctly moving the array pointer forward for RAW samples.

Cc David Ahern <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
[ committer note: Fix also later submitted by Jiri Olsa ]
---
 tools/perf/util/evsel.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/util/evsel.c +2 -0
index d9da62a..8c13dbc 100644
@@ -580,6 +580,8 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
 			return -EFAULT;
 
 		data->raw_data = (void *) pdata;
+
+		array = (void *)array + data->raw_size + sizeof(u32);
 	}
 
 	if (type & PERF_SAMPLE_BRANCH_STACK) {