Skip to content

Commit

Permalink
perf: Use read() instead of lseek() in trace_event_read.c:skip()
Browse files Browse the repository at this point in the history
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 d00a47c 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>
  • Loading branch information
Tom Zanussi authored and Frederic Weisbecker committed May 20, 2010
1 parent 537b60d commit cbb5cf7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions tools/perf/util/trace-event-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ static unsigned long page_size;
static ssize_t calc_data_size;
static bool repipe;

/* If it fails, the next read will report it */
static void skip(int size)
{
lseek(input_fd, size, SEEK_CUR);
}

static int do_read(int fd, void *buf, int size)
{
int rsize = size;
Expand Down Expand Up @@ -98,6 +92,19 @@ static int read_or_die(void *data, int size)
return r;
}

/* If it fails, the next read will report it */
static void skip(int size)
{
char buf[BUFSIZ];
int r;

while (size) {
r = size > BUFSIZ ? BUFSIZ : size;
read_or_die(buf, r);
size -= r;
};
}

static unsigned int read4(void)
{
unsigned int data;
Expand Down

0 comments on commit cbb5cf7

Please sign in to comment.