Patch "perf inject: Copy events when reordering events in pipe mode" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
perf inject: Copy events when reordering events in pipe mode
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
perf-inject-copy-events-when-reordering-events-in-pipe-mode.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Sun Mar 18 16:55:33 CET 2018
From: David Carrillo-Cisneros <[email protected]>
Date: Mon, 10 Apr 2017 13:14:27 -0700
Subject: perf inject: Copy events when reordering events in pipe mode
From: David Carrillo-Cisneros <[email protected]>
[ Upstream commit 1e0d4f0200e4dbdfc38d818f329d8a0955f7c6f5 ]
__perf_session__process_pipe_events reuses the same memory buffer to process all events in the pipe.
When reordering is needed (e.g. -b option), events are not immediately flushed, but kept around until reordering is possible, causing memory corruption.
The problem is usually observed by a "Unknown sample error" output. It can easily be reproduced by:
perf record -o - noploop | perf inject -b > output
Committer testing:
Before:
$ perf record -o - stress -t 2 -c 2 | perf inject -b > /dev/null stress: info: [8297] dispatching hogs: 2 cpu, 0 io, 0 vm, 0 hdd stress: info: [8297] successful run completed in 2s [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 0.000 MB - ] Warning: Found 1 unknown events!
Is this an older tool processing a perf.data file generated by a more recent tool?
If that is not the case, consider reporting to [email protected].
$
After:
$ perf record -o - stress -t 2 -c 2 | perf inject -b > /dev/null stress: info: [9027] dispatching hogs: 2 cpu, 0 io, 0 vm, 0 hdd stress: info: [9027] successful run completed in 2s [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 0.000 MB - ] no symbols found in /usr/bin/stress, maybe install a debug package? no symbols found in /usr/bin/stress, maybe install a debug package? $
--- tools/perf/util/ordered-events.c | 3 ++- tools/perf/util/session.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/ordered-events.c +2 -1
@@ -79,7 +79,7 @@ static union perf_event *dup_event(strucstatic void free_dup_event (struct ordered_events *oe,union perf_event *event) { -if (oe->copy_on_queue) { +if (event && oe->copy_on_queue) { oe->cur_alloc_size -= event->header.size;free (event); }
@@ -150,6 +150,7 @@ void ordered_events__delete(struct orderlist_move (&event->list, &oe->cache); oe->nr_events--;free_dup_event (oe, event->event); + event->event =NULL ; } int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
tools/perf/util/session.c +1 -0
@@ -1628,6 +1628,7 @@ static int __perf_session__process_pipe_ buf =malloc (cur_size);if (!buf)return -errno; +ordered_events__set_copy_on_queue (oe, true); more: event = buf; err =readn (fd, event,sizeof (struct perf_event_header ));
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/perf-session-don-t-rely-on-evlist-in-pipe-mode.patch queue-4.9/perf-inject-copy-events-when-reordering-events-in-pipe-mode.patch queue-4.9/perf-stat-fix-bug-in-handling-events-in-error-state.patch