Skip to contentSkip to conversation

perf: Fix unincremented buffer base on partial copy

PATCH In review Frederic Weisbecker 1 participant 2 messages May 27, 2010 – May 31, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: Fix unincremented buffer base on partial copy

If a sample size crosses to the next page boundary, the copy will be made in more than one step. However we forget to advance the source offset for the next copy, leading to unexpected double copies that completely mess up the traces.

This fixes various kinds of bad traces that have irrelevant datas inside, as an example:

	geany-4979  [001]  5758.077775: sched_switch: prev_comm=! prev_pid=121
		prev_prio=0 prev_state=S|D|Z|X|x ==> next_comm= next_pid=7497072
		next_prio=0
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Paul Mackerras <[email protected]>
---
 kernel/perf_event.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/perf_event.c +1 -0
index e099650..3d82e1a 100644
@@ -2977,6 +2977,7 @@ __always_inline void perf_output_copy(struct perf_output_handle *handle,
 
 		len -= size;
 		handle->addr += size;
+		buf += size;
 		handle->size -= size;
 		if (!handle->size) {
 			struct perf_mmap_data *data = handle->data;
Signature · 1 line
1.6.2.3
#1 lore raw

[tip:perf/urgent] perf_events: Fix unincremented buffer base on partial copy

Commit-ID:  74048f895fa8cbf8119b4999f1f44881a825f954
Gitweb:     http://git.kernel.org/tip/74048f895fa8cbf8119b4999f1f44881a825f954
Author:     Frederic Weisbecker <[email protected]>
AuthorDate: Thu, 27 May 2010 21:34:58 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 31 May 2010 08:46:10 +0200

perf_events: Fix unincremented buffer base on partial copy

If a sample size crosses to the next page boundary, the copy will be made in more than one step. However we forget to advance the source offset for the next copy, leading to unexpected double copies that completely mess up the traces.

This fixes various kinds of bad traces that have irrelevant data inside, as an example:

	geany-4979  [001]  5758.077775: sched_switch: prev_comm=! prev_pid=121
		prev_prio=0 prev_state=S|D|Z|X|x ==> next_comm= next_pid=7497072
		next_prio=0
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Paul Mackerras <[email protected]>

LKML-Reference: <[email protected]>

---
 kernel/perf_event.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/perf_event.c +1 -0
index 42a0e91..858f56f 100644
@@ -3064,6 +3064,7 @@ __always_inline void perf_output_copy(struct perf_output_handle *handle,
 
 		len -= size;
 		handle->addr += size;
+		buf += size;
 		handle->size -= size;
 		if (!handle->size) {
 			struct perf_mmap_data *data = handle->data;