All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf record: Fix poll return value propagation
@ 2014-06-02 18:02 Jiri Olsa
  2014-06-02 19:18 ` Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jiri Olsa @ 2014-06-02 18:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford, David Ahern,
	Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
	Peter Zijlstra

If the perf record command is interrupted in record__mmap_read_all
function, the 'done' is set and err has the latest poll return
value, which is most likely positive number (= number of pollfds
ready to read).

This 'positive err' is then propagated to the exit code, resulting
in not finishing the perf.data header properly, causing following
error in report:

  # perf record -F 50000 -a

  ---
  make the system real busy, so there's more chance
  to interrupt perf in event writing code
  ---

  ^C[ perf record: Woken up 16 times to write data ]
  [ perf record: Captured and wrote 30.292 MB perf.data (~1323468 samples) ]

  # perf report --stdio > /dev/null
  WARNING: The perf.data file's data size field is 0 which is unexpected.
  Was the 'perf record' command properly terminated?

Fixing this by checking for positive poll return value
and setting err to 0.

Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-record.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e4c85b8..ce2cfec 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -454,7 +454,11 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 			if (done)
 				break;
 			err = poll(rec->evlist->pollfd, rec->evlist->nr_fds, -1);
-			if (err < 0 && errno == EINTR)
+			/*
+			 * Propagate error, only if there's any. Ignore positive
+			 * number of returned events and interrupt error.
+			 */
+			if (err > 0 || (err < 0 && errno == EINTR))
 				err = 0;
 			waking++;
 		}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf record: Fix poll return value propagation
  2014-06-02 18:02 [PATCH] perf record: Fix poll return value propagation Jiri Olsa
@ 2014-06-02 19:18 ` Arnaldo Carvalho de Melo
  2014-06-03  3:21 ` Namhyung Kim
  2014-06-05 14:32 ` [tip:perf/core] " tip-bot for Jiri Olsa
  2 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-06-02 19:18 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Corey Ashford, David Ahern, Frederic Weisbecker,
	Ingo Molnar, Namhyung Kim, Paul Mackerras, Peter Zijlstra

Em Mon, Jun 02, 2014 at 08:02:06PM +0200, Jiri Olsa escreveu:
> If the perf record command is interrupted in record__mmap_read_all
> function, the 'done' is set and err has the latest poll return
> value, which is most likely positive number (= number of pollfds
> ready to read).
> 
> This 'positive err' is then propagated to the exit code, resulting
> in not finishing the perf.data header properly, causing following
> error in report:
> 
>   # perf record -F 50000 -a

Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf record: Fix poll return value propagation
  2014-06-02 18:02 [PATCH] perf record: Fix poll return value propagation Jiri Olsa
  2014-06-02 19:18 ` Arnaldo Carvalho de Melo
@ 2014-06-03  3:21 ` Namhyung Kim
  2014-06-05 14:32 ` [tip:perf/core] " tip-bot for Jiri Olsa
  2 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2014-06-03  3:21 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Corey Ashford,
	David Ahern, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
	Peter Zijlstra

On Mon,  2 Jun 2014 20:02:06 +0200, Jiri Olsa wrote:
> If the perf record command is interrupted in record__mmap_read_all
> function, the 'done' is set and err has the latest poll return
> value, which is most likely positive number (= number of pollfds
> ready to read).
>
> This 'positive err' is then propagated to the exit code, resulting
> in not finishing the perf.data header properly, causing following
> error in report:
>
>   # perf record -F 50000 -a
>
>   ---
>   make the system real busy, so there's more chance
>   to interrupt perf in event writing code
>   ---
>
>   ^C[ perf record: Woken up 16 times to write data ]
>   [ perf record: Captured and wrote 30.292 MB perf.data (~1323468 samples) ]
>
>   # perf report --stdio > /dev/null
>   WARNING: The perf.data file's data size field is 0 which is unexpected.
>   Was the 'perf record' command properly terminated?
>
> Fixing this by checking for positive poll return value
> and setting err to 0.

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/core] perf record: Fix poll return value propagation
  2014-06-02 18:02 [PATCH] perf record: Fix poll return value propagation Jiri Olsa
  2014-06-02 19:18 ` Arnaldo Carvalho de Melo
  2014-06-03  3:21 ` Namhyung Kim
@ 2014-06-05 14:32 ` tip-bot for Jiri Olsa
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Jiri Olsa @ 2014-06-05 14:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, paulus, acme, hpa, mingo, jolsa, a.p.zijlstra,
	acme, namhyung, fweisbec, dsahern, tglx, cjashfor

Commit-ID:  a515114fa3cff8f1da10cd68914d55c10879c3e0
Gitweb:     http://git.kernel.org/tip/a515114fa3cff8f1da10cd68914d55c10879c3e0
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 2 Jun 2014 13:44:23 -0400
Committer:  Jiri Olsa <jolsa@kernel.org>
CommitDate: Tue, 3 Jun 2014 21:35:05 +0200

perf record: Fix poll return value propagation

If the perf record command is interrupted in record__mmap_read_all
function, the 'done' is set and err has the latest poll return
value, which is most likely positive number (= number of pollfds
ready to read).

This 'positive err' is then propagated to the exit code, resulting
in not finishing the perf.data header properly, causing following
error in report:

  # perf record -F 50000 -a

  ---
  make the system real busy, so there's more chance
  to interrupt perf in event writing code
  ---

  ^C[ perf record: Woken up 16 times to write data ]
  [ perf record: Captured and wrote 30.292 MB perf.data (~1323468 samples) ]

  # perf report --stdio > /dev/null
  WARNING: The perf.data file's data size field is 0 which is unexpected.
  Was the 'perf record' command properly terminated?

Fixing this by checking for positive poll return value
and setting err to 0.

Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1401732126-19465-1-git-send-email-jolsa@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-record.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e4c85b8..ce2cfec 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -454,7 +454,11 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 			if (done)
 				break;
 			err = poll(rec->evlist->pollfd, rec->evlist->nr_fds, -1);
-			if (err < 0 && errno == EINTR)
+			/*
+			 * Propagate error, only if there's any. Ignore positive
+			 * number of returned events and interrupt error.
+			 */
+			if (err > 0 || (err < 0 && errno == EINTR))
 				err = 0;
 			waking++;
 		}

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-05 14:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-02 18:02 [PATCH] perf record: Fix poll return value propagation Jiri Olsa
2014-06-02 19:18 ` Arnaldo Carvalho de Melo
2014-06-03  3:21 ` Namhyung Kim
2014-06-05 14:32 ` [tip:perf/core] " tip-bot for Jiri Olsa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.