linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] perf scripts: Fix rwtop script
@ 2013-02-05 16:05 Jiri Olsa
  2013-02-05 16:05 ` [PATCH 1/2] perf scripts: Fix SIGALRM and pipe read race for rwtop Jiri Olsa
  2013-02-05 16:05 ` [PATCH 2/2] perf scripts: Fix rwtop record script Jiri Olsa
  0 siblings, 2 replies; 6+ messages in thread
From: Jiri Olsa @ 2013-02-05 16:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Paul Mackerras, Corey Ashford, Frederic Weisbecker, Namhyung Kim,
	Andrew Jones, David Ahern

hi,
sending patches for rwtop race issue caused by rwtop script
triggering SIGALRM and underneath pipe reading layer reporting
error when interrupted.

It's discussed in here:
https://lkml.org/lkml/2012/9/14/381

thanks,
jirka

Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Andrew Jones <drjones@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
---
Jiri Olsa (2):
      perf scripts: Fix SIGALRM and pipe read race for rwtop
      perf scripts: Fix rwtop record script

 tools/perf/scripts/perl/bin/rwtop-record | 2 +-
 tools/perf/scripts/perl/rwtop.pl         | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

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

* [PATCH 1/2] perf scripts: Fix SIGALRM and pipe read race for rwtop
  2013-02-05 16:05 [PATCH 0/2] perf scripts: Fix rwtop script Jiri Olsa
@ 2013-02-05 16:05 ` Jiri Olsa
  2013-02-06 22:11   ` [tip:perf/core] perf perl " tip-bot for Jiri Olsa
  2013-02-05 16:05 ` [PATCH 2/2] perf scripts: Fix rwtop record script Jiri Olsa
  1 sibling, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2013-02-05 16:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Paul Mackerras, Corey Ashford, Frederic Weisbecker, Namhyung Kim,
	Andrew Jones, David Ahern

Fixing rwtop script race. The issue is caused by rwtop
script triggering SIGALRM and underneath pipe reading
layer reporting error when interrupted.

Fixing this by setting SA_RESTART for rwtop SIGALRM handler,
which avoids interruption of the pipe reading layer.

The discussion for this issue & fix is here:
https://lkml.org/lkml/2012/9/18/123

Original-patch-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Andrew Jones <drjones@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
---
 tools/perf/scripts/perl/rwtop.pl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/scripts/perl/rwtop.pl b/tools/perf/scripts/perl/rwtop.pl
index 4bb3ecd..8b20787 100644
--- a/tools/perf/scripts/perl/rwtop.pl
+++ b/tools/perf/scripts/perl/rwtop.pl
@@ -17,6 +17,7 @@ use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
 use lib "./Perf-Trace-Util/lib";
 use Perf::Trace::Core;
 use Perf::Trace::Util;
+use POSIX qw/SIGALRM SA_RESTART/;
 
 my $default_interval = 3;
 my $nlines = 20;
@@ -90,7 +91,10 @@ sub syscalls::sys_enter_write
 
 sub trace_begin
 {
-    $SIG{ALRM} = \&set_print_pending;
+    my $sa = POSIX::SigAction->new(\&set_print_pending);
+    $sa->flags(SA_RESTART);
+    $sa->safe(1);
+    POSIX::sigaction(SIGALRM, $sa) or die "Can't set SIGALRM handler: $!\n";
     alarm 1;
 }
 
-- 
1.7.11.7


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

* [PATCH 2/2] perf scripts: Fix rwtop record script
  2013-02-05 16:05 [PATCH 0/2] perf scripts: Fix rwtop script Jiri Olsa
  2013-02-05 16:05 ` [PATCH 1/2] perf scripts: Fix SIGALRM and pipe read race for rwtop Jiri Olsa
@ 2013-02-05 16:05 ` Jiri Olsa
  2013-02-05 16:15   ` David Ahern
  1 sibling, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2013-02-05 16:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Paul Mackerras, Corey Ashford, Frederic Weisbecker, Namhyung Kim,
	Andrew Jones, David Ahern

Adding -D option into the rwtop record command line, to get
immediate response when there's event in the buffer.

Otherwise we need to wait till half of the buffer is filled,
which is the default wattermark if it's not set.

Suggested-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Andrew Jones <drjones@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
---
 tools/perf/scripts/perl/bin/rwtop-record | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/scripts/perl/bin/rwtop-record b/tools/perf/scripts/perl/bin/rwtop-record
index 7cb9db2..e4ec090 100644
--- a/tools/perf/scripts/perl/bin/rwtop-record
+++ b/tools/perf/scripts/perl/bin/rwtop-record
@@ -1,2 +1,2 @@
 #!/bin/bash
-perf record -e syscalls:sys_enter_read -e syscalls:sys_exit_read -e syscalls:sys_enter_write -e syscalls:sys_exit_write $@
+perf record -e syscalls:sys_enter_read -e syscalls:sys_exit_read -e syscalls:sys_enter_write -e syscalls:sys_exit_write -D $@
-- 
1.7.11.7


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

* Re: [PATCH 2/2] perf scripts: Fix rwtop record script
  2013-02-05 16:05 ` [PATCH 2/2] perf scripts: Fix rwtop record script Jiri Olsa
@ 2013-02-05 16:15   ` David Ahern
  2013-02-06 12:48     ` Jiri Olsa
  0 siblings, 1 reply; 6+ messages in thread
From: David Ahern @ 2013-02-05 16:15 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Peter Zijlstra,
	Ingo Molnar, Paul Mackerras, Corey Ashford, Frederic Weisbecker,
	Namhyung Kim, Andrew Jones

On 2/5/13 9:05 AM, Jiri Olsa wrote:
> Adding -D option into the rwtop record command line, to get
> immediate response when there's event in the buffer.

Seems like this will dramatically increase CPU usage of perf-record as 
well as increase the overhead of each event with a process wakeup. How 
about a poll option on perf-record to have it wake up at a given rate 
instead?

David

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

* Re: [PATCH 2/2] perf scripts: Fix rwtop record script
  2013-02-05 16:15   ` David Ahern
@ 2013-02-06 12:48     ` Jiri Olsa
  0 siblings, 0 replies; 6+ messages in thread
From: Jiri Olsa @ 2013-02-06 12:48 UTC (permalink / raw)
  To: David Ahern
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Peter Zijlstra,
	Ingo Molnar, Paul Mackerras, Corey Ashford, Frederic Weisbecker,
	Namhyung Kim, Andrew Jones

On Tue, Feb 05, 2013 at 09:15:20AM -0700, David Ahern wrote:
> On 2/5/13 9:05 AM, Jiri Olsa wrote:
> >Adding -D option into the rwtop record command line, to get
> >immediate response when there's event in the buffer.
> 
> Seems like this will dramatically increase CPU usage of perf-record
> as well as increase the overhead of each event with a process
> wakeup. How about a poll option on perf-record to have it wake up at
> a given rate instead?

right, I'll check

thanks,
jirka

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

* [tip:perf/core] perf perl scripts: Fix SIGALRM and pipe read race for rwtop
  2013-02-05 16:05 ` [PATCH 1/2] perf scripts: Fix SIGALRM and pipe read race for rwtop Jiri Olsa
@ 2013-02-06 22:11   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Jiri Olsa @ 2013-02-06 22:11 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, drjones, a.p.zijlstra,
	namhyung, jolsa, fweisbec, dsahern, tglx, cjashfor, mingo

Commit-ID:  b22e79395c0fe4c86dd35745a929366034386ccc
Gitweb:     http://git.kernel.org/tip/b22e79395c0fe4c86dd35745a929366034386ccc
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Tue, 5 Feb 2013 17:05:50 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 6 Feb 2013 18:09:27 -0300

perf perl scripts: Fix SIGALRM and pipe read race for rwtop

Fixing rwtop script race. The issue is caused by rwtop script triggering
SIGALRM and underneath pipe reading layer reporting error when
interrupted.

Fixing this by setting SA_RESTART for rwtop SIGALRM handler, which
avoids interruption of the pipe reading layer.

The discussion for this issue & fix is here:
https://lkml.org/lkml/2012/9/18/123

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Original-patch-by: Andrew Jones <drjones@redhat.com>
Cc: Andrew Jones <drjones@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
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/1360080351-3246-2-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/scripts/perl/rwtop.pl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/scripts/perl/rwtop.pl b/tools/perf/scripts/perl/rwtop.pl
index 4bb3ecd..8b20787 100644
--- a/tools/perf/scripts/perl/rwtop.pl
+++ b/tools/perf/scripts/perl/rwtop.pl
@@ -17,6 +17,7 @@ use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
 use lib "./Perf-Trace-Util/lib";
 use Perf::Trace::Core;
 use Perf::Trace::Util;
+use POSIX qw/SIGALRM SA_RESTART/;
 
 my $default_interval = 3;
 my $nlines = 20;
@@ -90,7 +91,10 @@ sub syscalls::sys_enter_write
 
 sub trace_begin
 {
-    $SIG{ALRM} = \&set_print_pending;
+    my $sa = POSIX::SigAction->new(\&set_print_pending);
+    $sa->flags(SA_RESTART);
+    $sa->safe(1);
+    POSIX::sigaction(SIGALRM, $sa) or die "Can't set SIGALRM handler: $!\n";
     alarm 1;
 }
 

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

end of thread, other threads:[~2013-02-06 22:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-05 16:05 [PATCH 0/2] perf scripts: Fix rwtop script Jiri Olsa
2013-02-05 16:05 ` [PATCH 1/2] perf scripts: Fix SIGALRM and pipe read race for rwtop Jiri Olsa
2013-02-06 22:11   ` [tip:perf/core] perf perl " tip-bot for Jiri Olsa
2013-02-05 16:05 ` [PATCH 2/2] perf scripts: Fix rwtop record script Jiri Olsa
2013-02-05 16:15   ` David Ahern
2013-02-06 12:48     ` Jiri Olsa

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