From: Frederic Weisbecker on 9 May 2010 16:50 From: Tom Zanussi <tzanussi(a)gmail.com> Some events, such as the PERF_RECORD_FINISHED_ROUND event consist of only an event header and no data. In this case, a 0-length payload will be read, and the 0 return value will be wrongly interpreted as an 'unexpected end of event stream'. This patch allows for proper handling of data-less events by skipping 0-length reads. Signed-off-by: Tom Zanussi <tzanussi(a)gmail.com> Cc: Arnaldo Carvalho de Melo <acme(a)redhat.com> Cc: Ingo Molnar <mingo(a)elte.hu> Cc: Peter Zijlstra <a.p.zijlstra(a)chello.nl> Cc: Paul Mackerras <paulus(a)samba.org> Cc: Masami Hiramatsu <mhiramat(a)redhat.com> LKML-Reference: <1273038527.6383.51.camel(a)tropicana> Signed-off-by: Frederic Weisbecker <fweisbec(a)gmail.com> --- tools/perf/util/session.c | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 9401909..00ab298 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -696,15 +696,18 @@ more: p = &event; p += sizeof(struct perf_event_header); - err = do_read(self->fd, p, size - sizeof(struct perf_event_header)); - if (err <= 0) { - if (err == 0) { - pr_err("unexpected end of event stream\n"); - goto done; - } + if (size - sizeof(struct perf_event_header)) { + err = do_read(self->fd, p, + size - sizeof(struct perf_event_header)); + if (err <= 0) { + if (err == 0) { + pr_err("unexpected end of event stream\n"); + goto done; + } - pr_err("failed to read event data\n"); - goto out_err; + pr_err("failed to read event data\n"); + goto out_err; + } } if (size == 0 || -- 1.6.2.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|
Pages: 1 Prev: Information about your X6 Concept Car. Next: [GIT PULL] perf updates |