linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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

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).