Linux Kernels

perf_events: Fix unincremented buffer base on partial copy

This change “perf_events: Fix unincremented buffer base on partial copy” (commit 74048f8) in Linux kernel is authored by Frederic Weisbecker <fweisbec [at] gmail.com> on Thu May 27 21:34:58 2010 +0200.

Description of "perf_events: Fix unincremented buffer base on partial copy"

The change “perf_events: Fix unincremented buffer base on partial copy” introduces changes as follows.

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

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1274988898-5639-1-git-send-regression-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Linux kernel releases containing commit 74048f8

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "perf_events: Fix unincremented buffer base on partial copy"

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 kernel/perf_event.c | 1 +
 1 file changed, 1 insertion(+)
 
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 42a0e9191af5..858f56fa2432 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -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;

The commit for this change in Linux stable tree is 74048f8 (patch).

Last modified: 2020/01/11 09:49