lkml.org 
[lkml]   [2016]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 04/10] perf python: Fix pyrf_evlist__read_on_cpu event consuming
Date
We can't consume the event before parsing it. Under heavy
load we could get caught by kernel writer overwriting the
event we're trying to parse.

Link: http://lkml.kernel.org/n/tip-8dbalvrufeisa4cioyd9k65i@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/python.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index d0c1267741ee..c68ef0319114 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -865,12 +865,14 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
PyObject *pyevent = pyrf_event__new(event);
struct pyrf_event *pevent = (struct pyrf_event *)pyevent;

- perf_evlist__mmap_consume(evlist, cpu);
-
if (pyevent == NULL)
return PyErr_NoMemory();

err = perf_evlist__parse_sample(evlist, event, &pevent->sample);
+
+ /* Consume the even only after we parsed it out. */
+ perf_evlist__mmap_consume(evlist, cpu);
+
if (err)
return PyErr_Format(PyExc_OSError,
"perf: can't parse sample, err=%d", err);
--
2.4.11
\
 
 \ /
  Last update: 2016-07-10 14:01    [W:0.212 / U:3.984 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site