* [PATCH] perf/trace: use read() instead of lseek() in trace_event_read.c:skip()
@ 2010-05-05 4:02 Tom Zanussi
2010-05-14 16:12 ` Borislav Petkov
2010-05-20 12:54 ` [tip:perf/core] perf: Use " tip-bot for Tom Zanussi
0 siblings, 2 replies; 7+ messages in thread
From: Tom Zanussi @ 2010-05-05 4:02 UTC (permalink / raw)
To: Frederic Weisbecker; +Cc: Ingo Molnar, Arnaldo Carvalho de Melo, linux-kernel
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.
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
---
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 cb54cd0..f55cc3a 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;
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;
--
1.6.4.GIT
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] perf/trace: use read() instead of lseek() in trace_event_read.c:skip()
2010-05-05 4:02 [PATCH] perf/trace: use read() instead of lseek() in trace_event_read.c:skip() Tom Zanussi
@ 2010-05-14 16:12 ` Borislav Petkov
2010-05-14 16:22 ` Frederic Weisbecker
2010-05-20 12:54 ` [tip:perf/core] perf: Use " tip-bot for Tom Zanussi
1 sibling, 1 reply; 7+ messages in thread
From: Borislav Petkov @ 2010-05-14 16:12 UTC (permalink / raw)
To: Tom Zanussi
Cc: Frederic Weisbecker, Ingo Molnar, Arnaldo Carvalho de Melo,
linux-kernel
From: Tom Zanussi <tzanussi@gmail.com>
Date: Tue, May 04, 2010 at 11:02:10PM -0500
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.
>
> Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
has this one landed in any tree in the meantime?
tip/perf/core doesn't have it.
--
Regards/Gruss,
Boris.
Operating Systems Research Center
Advanced Micro Devices, Inc.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] perf/trace: use read() instead of lseek() in trace_event_read.c:skip()
2010-05-14 16:12 ` Borislav Petkov
@ 2010-05-14 16:22 ` Frederic Weisbecker
0 siblings, 0 replies; 7+ messages in thread
From: Frederic Weisbecker @ 2010-05-14 16:22 UTC (permalink / raw)
To: Borislav Petkov
Cc: Tom Zanussi, Ingo Molnar, Arnaldo Carvalho de Melo, linux-kernel
On Fri, May 14, 2010 at 06:12:55PM +0200, Borislav Petkov wrote:
> From: Tom Zanussi <tzanussi@gmail.com>
> Date: Tue, May 04, 2010 at 11:02:10PM -0500
>
> 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.
> >
> > Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
>
> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:perf/core] perf: Use read() instead of lseek() in trace_event_read.c:skip()
2010-05-05 4:02 [PATCH] perf/trace: use read() instead of lseek() in trace_event_read.c:skip() Tom Zanussi
2010-05-14 16:12 ` Borislav Petkov
@ 2010-05-20 12:54 ` tip-bot for Tom Zanussi
2010-05-20 13:39 ` Pekka Enberg
1 sibling, 1 reply; 7+ messages in thread
From: tip-bot for Tom Zanussi @ 2010-05-20 12:54 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, paulus, acme, hpa, mingo, tzanussi, a.p.zijlstra,
fweisbec, tglx, mingo
Commit-ID: cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
Gitweb: http://git.kernel.org/tip/cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
Author: Tom Zanussi <tzanussi@gmail.com>
AuthorDate: Tue, 4 May 2010 23:02:10 -0500
Committer: Frederic Weisbecker <fweisbec@gmail.com>
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.
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>
---
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 cb54cd0..f55cc3a 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;
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;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [tip:perf/core] perf: Use read() instead of lseek() in trace_event_read.c:skip()
2010-05-20 12:54 ` [tip:perf/core] perf: Use " tip-bot for Tom Zanussi
@ 2010-05-20 13:39 ` Pekka Enberg
2010-05-20 13:41 ` H. Peter Anvin
2010-05-20 13:43 ` Frederic Weisbecker
0 siblings, 2 replies; 7+ messages in thread
From: Pekka Enberg @ 2010-05-20 13:39 UTC (permalink / raw)
To: mingo, hpa, acme, paulus, linux-kernel, tzanussi, a.p.zijlstra,
fweisbec, tglx, mingo
Cc: linux-tip-commits
On Thu, May 20, 2010 at 3:54 PM, tip-bot for Tom Zanussi
<tzanussi@gmail.com> wrote:
> Commit-ID: cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
> Gitweb: http://git.kernel.org/tip/cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
> Author: Tom Zanussi <tzanussi@gmail.com>
> AuthorDate: Tue, 4 May 2010 23:02:10 -0500
> Committer: Frederic Weisbecker <fweisbec@gmail.com>
> 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.
Out of curiosity: why doesn't lseek() work and why can't we fix that?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [tip:perf/core] perf: Use read() instead of lseek() in trace_event_read.c:skip()
2010-05-20 13:39 ` Pekka Enberg
@ 2010-05-20 13:41 ` H. Peter Anvin
2010-05-20 13:43 ` Frederic Weisbecker
1 sibling, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2010-05-20 13:41 UTC (permalink / raw)
To: Pekka Enberg
Cc: mingo, acme, paulus, linux-kernel, tzanussi, a.p.zijlstra,
fweisbec, tglx, mingo, linux-tip-commits
On 05/20/2010 06:39 AM, Pekka Enberg wrote:
> On Thu, May 20, 2010 at 3:54 PM, tip-bot for Tom Zanussi
> <tzanussi@gmail.com> wrote:
>> Commit-ID: cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
>> Gitweb: http://git.kernel.org/tip/cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
>> Author: Tom Zanussi <tzanussi@gmail.com>
>> AuthorDate: Tue, 4 May 2010 23:02:10 -0500
>> Committer: Frederic Weisbecker <fweisbec@gmail.com>
>> 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.
>
> 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
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [tip:perf/core] perf: Use read() instead of lseek() in trace_event_read.c:skip()
2010-05-20 13:39 ` Pekka Enberg
2010-05-20 13:41 ` H. Peter Anvin
@ 2010-05-20 13:43 ` Frederic Weisbecker
1 sibling, 0 replies; 7+ messages in thread
From: Frederic Weisbecker @ 2010-05-20 13:43 UTC (permalink / raw)
To: Pekka Enberg
Cc: mingo, hpa, acme, paulus, linux-kernel, tzanussi, a.p.zijlstra,
tglx, mingo, linux-tip-commits
On Thu, May 20, 2010 at 04:39:37PM +0300, Pekka Enberg wrote:
> On Thu, May 20, 2010 at 3:54 PM, tip-bot for Tom Zanussi
> <tzanussi@gmail.com> wrote:
> > Commit-ID: cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
> > Gitweb: http://git.kernel.org/tip/cbb5cf7ff6b298beacfe23db3386335b0b9c0a2d
> > Author: Tom Zanussi <tzanussi@gmail.com>
> > AuthorDate: Tue, 4 May 2010 23:02:10 -0500
> > Committer: Frederic Weisbecker <fweisbec@gmail.com>
> > 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.
>
> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-05-20 13:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-05 4:02 [PATCH] perf/trace: use read() instead of lseek() in trace_event_read.c:skip() Tom Zanussi
2010-05-14 16:12 ` Borislav Petkov
2010-05-14 16:22 ` Frederic Weisbecker
2010-05-20 12:54 ` [tip:perf/core] perf: Use " tip-bot for Tom Zanussi
2010-05-20 13:39 ` Pekka Enberg
2010-05-20 13:41 ` H. Peter Anvin
2010-05-20 13:43 ` Frederic Weisbecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).