diff options
author | Tom Zanussi <tzanussi@gmail.com> | 2010-05-05 00:02:10 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2010-05-20 02:37:17 -0400 |
commit | cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d (patch) | |
tree | 153901937a7ce3acffc536c48652e0d87a52685b /tools/perf | |
parent | 537b60d17894b7c19a6060feae40299d7109d6e7 (diff) |
perf: Use read() instead of lseek() in trace_event_read.c:skip()
This is a small fix for a problem affecting live-mode, introduced
recently:
root@tropicana:~# perf trace rwtop
perf trace started with Perl
script /root/libexec/perf-core/scripts/perl/rwtop.pl
Fatal: did not read header event
commit d00a47cce569a3e660a8c9de5d57af28d6a9f0f7 added a skip()
function to skip over e.g. header_page, but this doesn't work for
live mode. This patch re-implements skip() to use read() instead of
lseek() to fix that.
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1273032130.6383.28.camel@tropicana>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/trace-event-read.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index cb54cd002f49..f55cc3a765a1 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c | |||
@@ -53,12 +53,6 @@ static unsigned long page_size; | |||
53 | static ssize_t calc_data_size; | 53 | static ssize_t calc_data_size; |
54 | static bool repipe; | 54 | static bool repipe; |
55 | 55 | ||
56 | /* If it fails, the next read will report it */ | ||
57 | static void skip(int size) | ||
58 | { | ||
59 | lseek(input_fd, size, SEEK_CUR); | ||
60 | } | ||
61 | |||
62 | static int do_read(int fd, void *buf, int size) | 56 | static int do_read(int fd, void *buf, int size) |
63 | { | 57 | { |
64 | int rsize = size; | 58 | int rsize = size; |
@@ -98,6 +92,19 @@ static int read_or_die(void *data, int size) | |||
98 | return r; | 92 | return r; |
99 | } | 93 | } |
100 | 94 | ||
95 | /* If it fails, the next read will report it */ | ||
96 | static void skip(int size) | ||
97 | { | ||
98 | char buf[BUFSIZ]; | ||
99 | int r; | ||
100 | |||
101 | while (size) { | ||
102 | r = size > BUFSIZ ? BUFSIZ : size; | ||
103 | read_or_die(buf, r); | ||
104 | size -= r; | ||
105 | }; | ||
106 | } | ||
107 | |||
101 | static unsigned int read4(void) | 108 | static unsigned int read4(void) |
102 | { | 109 | { |
103 | unsigned int data; | 110 | unsigned int data; |