perf/trace: use read() instead of lseek() in trace_event_read.c:skip()
PATCH 1/1 perf/trace: use read() instead of lseek() in trace_event_read.c:skip()
Hi,
Here's a small fix for a problem affecting live-mode, introduced in the past day or so:
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.
--- tools/perf/util/trace-event-read.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
tools/perf/util/trace-event-read.c +13 -6
@@ -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;
@@ -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;
Signature · 1 line
1.6.4.GIT
From: Tom Zanussi <[email protected]>
Date: Tue, May 04, 2010 at 11:02:10PM -0500
Hi,
Quoted 7 lines
Here's a small fix for a problem affecting live-mode, introduced in the past day or so:
root@tropicana:~# perf trace rwtop perf trace started with Perl script /root/libexec/perf-core/scripts/perl/rwtop.pl
Quoted 8 lines
Fatal: did not read header event
commit
d00a47cce569a3e660a8c9de5d57af28d6a9f0f7added askip()function to skip over e.g.header_page, but this doesn't work for live mode. This patch re-implementsskip()to useread()instead oflseek()to fix that.Signed-off-by Tom Zanussi <[email protected]>
has this one landed in any tree in the meantime?
tip/perf/core doesn't have it.
Signature · 5 lines
Regards/Gruss, Boris. Operating Systems Research Center Advanced Micro Devices, Inc.
Frederic Weisbecker
AppliedQuoted 19 lines · Borislav Petkov
From: Tom Zanussi <[email protected]>
Date: Tue, May 04, 2010 at 11:02:10PM -0500Hi,
Quoted 14 lines
Here's a small fix for a problem affecting live-mode, introduced in the past day or so:
root@tropicana:~# perf trace rwtop perf trace started with Perl script /root/libexec/perf-core/scripts/perl/rwtop.plFatal: did not read header event
commit
d00a47cce569a3e660a8c9de5d57af28d6a9f0f7added askip()function to skip over e.g.header_page, but this doesn't work for live mode. This patch re-implementsskip()to useread()instead oflseek()to fix that.
Quoted 5 lines
Quoted 1 line
Signed-off-by Tom Zanussi <[email protected]>has this one landed in any tree in the meantime?
tip/perf/core doesn't have it.
I forgot to queue it, my bad.
Queued, thanks.
[tip:perf/core] perf: Use read() instead of lseek() in trace_event_read.c:skip()
In reply to Tom ZanussiCommit-ID: cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d Gitweb: http://git.kernel.org/tip/cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d Author: Tom Zanussi <[email protected]> AuthorDate: Tue, 4 May 2010 23:02:10 -0500 Committer: Frederic Weisbecker <[email protected]> CommitDate: Thu, 20 May 2010 08:37:17 +0200
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.
LKML-Reference: <1273032130.6383.28.camel@tropicana>
--- tools/perf/util/trace-event-read.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
tools/perf/util/trace-event-read.c +13 -6
@@ -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;
@@ -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;
Re: [tip:perf/core] perf: Use read() instead of lseek() in trace_event_read.c:skip()
Quoted 16 lines · tip-bot for Tom Zanussi
Commit-ID: cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
Gitweb: http://git.kernel.org/tip/cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
Author: Tom Zanussi <[email protected]>
AuthorDate: Tue, 4 May 2010 23:02:10 -0500
Committer: Frederic Weisbecker <[email protected]>
CommitDate: Thu, 20 May 2010 08:37:17 +0200perf: Use
read()instead oflseek()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
Quoted 6 lines
Fatal: did not read header event
commit
d00a47cce569a3e660a8c9de5d57af28d6a9f0f7added askip()function to skip over e.g.header_page, but this doesn't work for live mode. This patch re-implementsskip()to useread()instead oflseek()to fix that.
Out of curiosity: why doesn't lseek() work and why can't we fix that?
Re: [tip:perf/core] perf: Use read() instead of lseek() in trace_event_read.c:skip()
Quoted 18 lines · Pekka Enberg
Quoted 16 lines · tip-bot for Tom Zanussi
Commit-ID: cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
Gitweb: http://git.kernel.org/tip/cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
Author: Tom Zanussi <[email protected]>
AuthorDate: Tue, 4 May 2010 23:02:10 -0500
Committer: Frederic Weisbecker <[email protected]>
CommitDate: Thu, 20 May 2010 08:37:17 +0200perf: Use
read()instead oflseek()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
Quoted 8 lines
Quoted 6 lines
Fatal: did not read header event
commit
d00a47cce569a3e660a8c9de5d57af28d6a9f0f7added askip()function to skip over e.g.header_page, but this doesn't work for live mode. This patch re-implementsskip()to useread()instead oflseek()to fix that.Out of curiosity: why doesn't
lseek()work and why can't we fix that?
Because depending on the mode we are, that may or may not work.
We have the normal mode, when the input in a regular file (perf.data) where it works. And we have the pipe mode, where the seek fails.
Re: [tip:perf/core] perf: Use read() instead of lseek() in trace_event_read.c:skip()
In reply to Pekka EnbergQuoted 18 lines · Pekka Enberg
Quoted 16 lines · tip-bot for Tom Zanussi
Commit-ID: cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d Gitweb: http://git.kernel.org/tip/cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d Author: Tom Zanussi <[email protected]> AuthorDate: Tue, 4 May 2010 23:02:10 -0500 Committer: Frederic Weisbecker <[email protected]> CommitDate: Thu, 20 May 2010 08:37:17 +0200perf: Use
read()instead oflseek()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
Quoted 8 lines
Quoted 6 lines
Fatal: did not read header event
commit
d00a47cce569a3e660a8c9de5d57af28d6a9f0f7added askip()function to skip over e.g.header_page, but this doesn't work for live mode. This patch re-implementsskip()to useread()instead oflseek()to fix that.Out of curiosity: why doesn't
lseek()work and why can't we fix that?
Presumably because we're reading from a nonseekable stream?
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.