All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf trace: get rid of the hard-coded paths in the report scripts
@ 2010-08-12 17:59 Tom Zanussi
  2010-08-12 18:20 ` Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Tom Zanussi @ 2010-08-12 17:59 UTC (permalink / raw)
  To: eranian; +Cc: linux-kernel, acme, mingo, acme, fweisbec, peterz

The perf trace report shell scripts hard-code the exec path of the
scripts into their command-lines, which doesn't work if perf has been
installed somewhere else.

Instead, perf trace should create the paths at run-time.  This patch
does that and removes the hard-coded paths from all the report scripts.

v2 changes: The first version inadvertantly caused scripts run from
outside the perf exec path to fail e.g. 'perf trace -s test.py'.  The
fix is to try the script name without the exec path first, then the
version using the exec path, which restores the expected behavior.

Reported-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
---
 tools/perf/builtin-trace.c                         |   22 ++++++++++++++++---
 tools/perf/scripts/perl/bin/failed-syscalls-report |    2 +-
 tools/perf/scripts/perl/bin/rw-by-file-report      |    2 +-
 tools/perf/scripts/perl/bin/rw-by-pid-report       |    2 +-
 tools/perf/scripts/perl/bin/rwtop-report           |    2 +-
 tools/perf/scripts/perl/bin/wakeup-latency-report  |    2 +-
 tools/perf/scripts/perl/bin/workqueue-stats-report |    2 +-
 .../python/bin/failed-syscalls-by-pid-report       |    2 +-
 .../perf/scripts/python/bin/sched-migration-report |    2 +-
 tools/perf/scripts/python/bin/sctop-report         |    2 +-
 .../python/bin/syscall-counts-by-pid-report        |    2 +-
 .../perf/scripts/python/bin/syscall-counts-report  |    3 +-
 12 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 40a6a29..88a1883 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -573,6 +573,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
 	const char *suffix = NULL;
 	const char **__argv;
 	char *script_path;
+	struct stat perf_stat;
 	int i, err;
 
 	if (argc >= 2 && strncmp(argv[1], "rec", strlen("rec")) == 0) {
@@ -689,8 +690,6 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
 		return -EINVAL;
 
 	if (generate_script_lang) {
-		struct stat perf_stat;
-
 		int input = open(input_name, O_RDONLY);
 		if (input < 0) {
 			perror("failed to open file");
@@ -719,10 +718,25 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
 	}
 
 	if (script_name) {
-		err = scripting_ops->start_script(script_name, argc, argv);
+		char script_exec_path[MAXPATHLEN];
+
+		snprintf(script_exec_path, MAXPATHLEN, "%s", script_name);
+		err = stat(script_exec_path, &perf_stat);
+		if (err < 0) {
+			snprintf(script_exec_path, MAXPATHLEN, "%s/scripts/%s",
+				 perf_exec_path(), script_name);
+			err = stat(script_exec_path, &perf_stat);
+			if (err < 0)
+				goto out;
+		}
+
+		err = scripting_ops->start_script(script_exec_path,
+						  argc, argv);
 		if (err)
 			goto out;
-		pr_debug("perf trace started with script %s\n\n", script_name);
+
+		pr_debug("perf trace started with script %s\n\n",
+			 script_exec_path);
 	}
 
 	err = __cmd_trace(session);
diff --git a/tools/perf/scripts/perl/bin/failed-syscalls-report b/tools/perf/scripts/perl/bin/failed-syscalls-report
index e3a5e55..47cf0b7 100644
--- a/tools/perf/scripts/perl/bin/failed-syscalls-report
+++ b/tools/perf/scripts/perl/bin/failed-syscalls-report
@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/failed-syscalls.pl $comm
+perf trace $@ -s perl/failed-syscalls.pl $comm
diff --git a/tools/perf/scripts/perl/bin/rw-by-file-report b/tools/perf/scripts/perl/bin/rw-by-file-report
index d83070b..407ec70 100644
--- a/tools/perf/scripts/perl/bin/rw-by-file-report
+++ b/tools/perf/scripts/perl/bin/rw-by-file-report
@@ -7,7 +7,7 @@ if [ $# -lt 1 ] ; then
 fi
 comm=$1
 shift
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-file.pl $comm
+perf trace $@ -s perl/rw-by-file.pl $comm
 
 
 
diff --git a/tools/perf/scripts/perl/bin/rw-by-pid-report b/tools/perf/scripts/perl/bin/rw-by-pid-report
index 7ef4698..0c129e1 100644
--- a/tools/perf/scripts/perl/bin/rw-by-pid-report
+++ b/tools/perf/scripts/perl/bin/rw-by-pid-report
@@ -1,6 +1,6 @@
 #!/bin/bash
 # description: system-wide r/w activity
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-pid.pl
+perf trace $@ -s perl/rw-by-pid.pl
 
 
 
diff --git a/tools/perf/scripts/perl/bin/rwtop-report b/tools/perf/scripts/perl/bin/rwtop-report
index 93e698c..5bac5bb 100644
--- a/tools/perf/scripts/perl/bin/rwtop-report
+++ b/tools/perf/scripts/perl/bin/rwtop-report
@@ -17,7 +17,7 @@ if [ "$n_args" -gt 0 ] ; then
     interval=$1
     shift
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rwtop.pl $interval
+perf trace $@ -s perl/rwtop.pl $interval
 
 
 
diff --git a/tools/perf/scripts/perl/bin/wakeup-latency-report b/tools/perf/scripts/perl/bin/wakeup-latency-report
index a0d898f..dcfdd05 100644
--- a/tools/perf/scripts/perl/bin/wakeup-latency-report
+++ b/tools/perf/scripts/perl/bin/wakeup-latency-report
@@ -1,6 +1,6 @@
 #!/bin/bash
 # description: system-wide min/max/avg wakeup latency
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/wakeup-latency.pl
+perf trace $@ -s perl/wakeup-latency.pl
 
 
 
diff --git a/tools/perf/scripts/perl/bin/workqueue-stats-report b/tools/perf/scripts/perl/bin/workqueue-stats-report
index 3508113..6ce9247 100644
--- a/tools/perf/scripts/perl/bin/workqueue-stats-report
+++ b/tools/perf/scripts/perl/bin/workqueue-stats-report
@@ -1,6 +1,6 @@
 #!/bin/bash
 # description: workqueue stats (ins/exe/create/destroy)
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/workqueue-stats.pl
+perf trace $@ -s perl/workqueue-stats.pl
 
 
 
diff --git a/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report b/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report
index 3029354..b39182f 100644
--- a/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report
+++ b/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report
@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/failed-syscalls-by-pid.py $comm
+perf trace $@ -s python/failed-syscalls-by-pid.py $comm
diff --git a/tools/perf/scripts/python/bin/sched-migration-report b/tools/perf/scripts/python/bin/sched-migration-report
index 61d05f7..8299b69 100644
--- a/tools/perf/scripts/python/bin/sched-migration-report
+++ b/tools/perf/scripts/python/bin/sched-migration-report
@@ -1,3 +1,3 @@
 #!/bin/bash
 # description: sched migration overview
-perf trace $@ -s ~/libexec/perf-core/scripts/python/sched-migration.py
+perf trace $@ -s python/sched-migration.py
diff --git a/tools/perf/scripts/python/bin/sctop-report b/tools/perf/scripts/python/bin/sctop-report
index b01c842..9fe812c 100644
--- a/tools/perf/scripts/python/bin/sctop-report
+++ b/tools/perf/scripts/python/bin/sctop-report
@@ -21,4 +21,4 @@ elif [ "$n_args" -gt 0 ] ; then
     interval=$1
     shift
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/sctop.py $comm $interval
+perf trace $@ -s python/sctop.py $comm $interval
diff --git a/tools/perf/scripts/python/bin/syscall-counts-by-pid-report b/tools/perf/scripts/python/bin/syscall-counts-by-pid-report
index 9e9d8dd..ec9d4d9 100644
--- a/tools/perf/scripts/python/bin/syscall-counts-by-pid-report
+++ b/tools/perf/scripts/python/bin/syscall-counts-by-pid-report
@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts-by-pid.py $comm
+perf trace $@ -s python/syscall-counts-by-pid.py $comm
diff --git a/tools/perf/scripts/python/bin/syscall-counts-report b/tools/perf/scripts/python/bin/syscall-counts-report
index dc076b6..9ed7854 100644
--- a/tools/perf/scripts/python/bin/syscall-counts-report
+++ b/tools/perf/scripts/python/bin/syscall-counts-report
@@ -1,3 +1,4 @@
+
 #!/bin/bash
 # description: system-wide syscall counts
 # args: [comm]
@@ -7,4 +8,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts.py $comm
+perf trace $@ -s python/syscall-counts.py $comm
-- 
1.6.5.rc2


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

* Re: [PATCH] perf trace: get rid of the hard-coded paths in the report scripts
  2010-08-12 17:59 [PATCH] perf trace: get rid of the hard-coded paths in the report scripts Tom Zanussi
@ 2010-08-12 18:20 ` Arnaldo Carvalho de Melo
  2010-08-12 21:29   ` Stephane Eranian
  2010-08-12 21:28 ` Stephane Eranian
  2010-08-13  8:30 ` Stephane Eranian
  2 siblings, 1 reply; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-08-12 18:20 UTC (permalink / raw)
  To: Tom Zanussi; +Cc: eranian, linux-kernel, mingo, fweisbec, peterz

Em Thu, Aug 12, 2010 at 12:59:18PM -0500, Tom Zanussi escreveu:
> The perf trace report shell scripts hard-code the exec path of the
> scripts into their command-lines, which doesn't work if perf has been
> installed somewhere else.
> 
> Instead, perf trace should create the paths at run-time.  This patch
> does that and removes the hard-coded paths from all the report scripts.
> 
> v2 changes: The first version inadvertantly caused scripts run from
> outside the perf exec path to fail e.g. 'perf trace -s test.py'.  The
> fix is to try the script name without the exec path first, then the
> version using the exec path, which restores the expected behavior.
> 
> Reported-by: Stephane Eranian <eranian@google.com>
> Signed-off-by: Tom Zanussi <tzanussi@gmail.com>

Stephane,

	Lemme know when you tried this patch so that I can merge it with
a Tested-by: you tag, ok?

- Arnaldo

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

* Re: [PATCH] perf trace: get rid of the hard-coded paths in the report scripts
  2010-08-12 17:59 [PATCH] perf trace: get rid of the hard-coded paths in the report scripts Tom Zanussi
  2010-08-12 18:20 ` Arnaldo Carvalho de Melo
@ 2010-08-12 21:28 ` Stephane Eranian
  2010-08-12 21:50   ` Tom Zanussi
  2010-08-13  8:30 ` Stephane Eranian
  2 siblings, 1 reply; 8+ messages in thread
From: Stephane Eranian @ 2010-08-12 21:28 UTC (permalink / raw)
  To: Tom Zanussi; +Cc: linux-kernel, acme, mingo, acme, fweisbec, peterz

On Thu, Aug 12, 2010 at 7:59 PM, Tom Zanussi <tzanussi@gmail.com> wrote:
> The perf trace report shell scripts hard-code the exec path of the
> scripts into their command-lines, which doesn't work if perf has been
> installed somewhere else.
>
> Instead, perf trace should create the paths at run-time.  This patch
> does that and removes the hard-coded paths from all the report scripts.
>
> v2 changes: The first version inadvertantly caused scripts run from
> outside the perf exec path to fail e.g. 'perf trace -s test.py'.  The
> fix is to try the script name without the exec path first, then the
> version using the exec path, which restores the expected behavior.
>
> Reported-by: Stephane Eranian <eranian@google.com>
> Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
> ---
>  tools/perf/builtin-trace.c                         |   22 ++++++++++++++++---
>  tools/perf/scripts/perl/bin/failed-syscalls-report |    2 +-
>  tools/perf/scripts/perl/bin/rw-by-file-report      |    2 +-
>  tools/perf/scripts/perl/bin/rw-by-pid-report       |    2 +-
>  tools/perf/scripts/perl/bin/rwtop-report           |    2 +-
>  tools/perf/scripts/perl/bin/wakeup-latency-report  |    2 +-
>  tools/perf/scripts/perl/bin/workqueue-stats-report |    2 +-
>  .../python/bin/failed-syscalls-by-pid-report       |    2 +-
>  .../perf/scripts/python/bin/sched-migration-report |    2 +-
>  tools/perf/scripts/python/bin/sctop-report         |    2 +-
>  .../python/bin/syscall-counts-by-pid-report        |    2 +-
>  .../perf/scripts/python/bin/syscall-counts-report  |    3 +-
>  12 files changed, 30 insertions(+), 15 deletions(-)
>
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 40a6a29..88a1883 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -573,6 +573,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
>        const char *suffix = NULL;
>        const char **__argv;
>        char *script_path;
> +       struct stat perf_stat;
>        int i, err;
>
>        if (argc >= 2 && strncmp(argv[1], "rec", strlen("rec")) == 0) {
> @@ -689,8 +690,6 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
>                return -EINVAL;
>
>        if (generate_script_lang) {
> -               struct stat perf_stat;
> -
>                int input = open(input_name, O_RDONLY);
>                if (input < 0) {
>                        perror("failed to open file");
> @@ -719,10 +718,25 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
>        }
>
>        if (script_name) {
> -               err = scripting_ops->start_script(script_name, argc, argv);
> +               char script_exec_path[MAXPATHLEN];
> +
> +               snprintf(script_exec_path, MAXPATHLEN, "%s", script_name);
> +               err = stat(script_exec_path, &perf_stat);

Why not simply use access() instead of stat() here?

> +               if (err < 0) {
> +                       snprintf(script_exec_path, MAXPATHLEN, "%s/scripts/%s",
> +                                perf_exec_path(), script_name);
> +                       err = stat(script_exec_path, &perf_stat);
And here?

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

* Re: [PATCH] perf trace: get rid of the hard-coded paths in the report scripts
  2010-08-12 18:20 ` Arnaldo Carvalho de Melo
@ 2010-08-12 21:29   ` Stephane Eranian
  0 siblings, 0 replies; 8+ messages in thread
From: Stephane Eranian @ 2010-08-12 21:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Tom Zanussi, linux-kernel, mingo, fweisbec, peterz

On Thu, Aug 12, 2010 at 8:20 PM, Arnaldo Carvalho de Melo
<acme@infradead.org> wrote:
> Em Thu, Aug 12, 2010 at 12:59:18PM -0500, Tom Zanussi escreveu:
>> The perf trace report shell scripts hard-code the exec path of the
>> scripts into their command-lines, which doesn't work if perf has been
>> installed somewhere else.
>>
>> Instead, perf trace should create the paths at run-time.  This patch
>> does that and removes the hard-coded paths from all the report scripts.
>>
>> v2 changes: The first version inadvertantly caused scripts run from
>> outside the perf exec path to fail e.g. 'perf trace -s test.py'.  The
>> fix is to try the script name without the exec path first, then the
>> version using the exec path, which restores the expected behavior.
>>
>> Reported-by: Stephane Eranian <eranian@google.com>
>> Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
>
> Stephane,
>
>        Lemme know when you tried this patch so that I can merge it with
> a Tested-by: you tag, ok?
>
Will get back to you tomorrow morning (your time).

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

* Re: [PATCH] perf trace: get rid of the hard-coded paths in the report scripts
  2010-08-12 21:28 ` Stephane Eranian
@ 2010-08-12 21:50   ` Tom Zanussi
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Zanussi @ 2010-08-12 21:50 UTC (permalink / raw)
  To: Stephane Eranian; +Cc: linux-kernel, acme, mingo, acme, fweisbec, peterz

On Thu, Aug 12, 2010 at 4:28 PM, Stephane Eranian <eranian@google.com> wrote:
> On Thu, Aug 12, 2010 at 7:59 PM, Tom Zanussi <tzanussi@gmail.com> wrote:
>> The perf trace report shell scripts hard-code the exec path of the
>> scripts into their command-lines, which doesn't work if perf has been
>> installed somewhere else.
>>
>> Instead, perf trace should create the paths at run-time.  This patch
>> does that and removes the hard-coded paths from all the report scripts.
>>
>> v2 changes: The first version inadvertantly caused scripts run from
>> outside the perf exec path to fail e.g. 'perf trace -s test.py'.  The
>> fix is to try the script name without the exec path first, then the
>> version using the exec path, which restores the expected behavior.
>>
>> Reported-by: Stephane Eranian <eranian@google.com>
>> Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
>> ---
>>  tools/perf/builtin-trace.c                         |   22 ++++++++++++++++---
>>  tools/perf/scripts/perl/bin/failed-syscalls-report |    2 +-
>>  tools/perf/scripts/perl/bin/rw-by-file-report      |    2 +-
>>  tools/perf/scripts/perl/bin/rw-by-pid-report       |    2 +-
>>  tools/perf/scripts/perl/bin/rwtop-report           |    2 +-
>>  tools/perf/scripts/perl/bin/wakeup-latency-report  |    2 +-
>>  tools/perf/scripts/perl/bin/workqueue-stats-report |    2 +-
>>  .../python/bin/failed-syscalls-by-pid-report       |    2 +-
>>  .../perf/scripts/python/bin/sched-migration-report |    2 +-
>>  tools/perf/scripts/python/bin/sctop-report         |    2 +-
>>  .../python/bin/syscall-counts-by-pid-report        |    2 +-
>>  .../perf/scripts/python/bin/syscall-counts-report  |    3 +-
>>  12 files changed, 30 insertions(+), 15 deletions(-)
>>
>> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
>> index 40a6a29..88a1883 100644
>> --- a/tools/perf/builtin-trace.c
>> +++ b/tools/perf/builtin-trace.c
>> @@ -573,6 +573,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
>>        const char *suffix = NULL;
>>        const char **__argv;
>>        char *script_path;
>> +       struct stat perf_stat;
>>        int i, err;
>>
>>        if (argc >= 2 && strncmp(argv[1], "rec", strlen("rec")) == 0) {
>> @@ -689,8 +690,6 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
>>                return -EINVAL;
>>
>>        if (generate_script_lang) {
>> -               struct stat perf_stat;
>> -
>>                int input = open(input_name, O_RDONLY);
>>                if (input < 0) {
>>                        perror("failed to open file");
>> @@ -719,10 +718,25 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
>>        }
>>
>>        if (script_name) {
>> -               err = scripting_ops->start_script(script_name, argc, argv);
>> +               char script_exec_path[MAXPATHLEN];
>> +
>> +               snprintf(script_exec_path, MAXPATHLEN, "%s", script_name);
>> +               err = stat(script_exec_path, &perf_stat);
>
> Why not simply use access() instead of stat() here?

Yeah, that would probably be better - if this patch works for you, I
can submit a follow-on patch to do that along with some other small
patches I'm hoping to get to over the weekend...

Thanks,

Tom

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

* Re: [PATCH] perf trace: get rid of the hard-coded paths in the report scripts
  2010-08-12 17:59 [PATCH] perf trace: get rid of the hard-coded paths in the report scripts Tom Zanussi
  2010-08-12 18:20 ` Arnaldo Carvalho de Melo
  2010-08-12 21:28 ` Stephane Eranian
@ 2010-08-13  8:30 ` Stephane Eranian
  2010-08-14  4:38   ` Tom Zanussi
  2 siblings, 1 reply; 8+ messages in thread
From: Stephane Eranian @ 2010-08-13  8:30 UTC (permalink / raw)
  To: Tom Zanussi; +Cc: linux-kernel, acme, mingo, acme, fweisbec, peterz

Tom,

Here is version that works for me. Besides the stat() to access() change, I fixed
the pathname you were building, it was missing the language name. The way I solved
that is by leveraging the scripting_ops->name field, but for that I had to make sure
it would match the subdir name, i.e., all lower-case. I also add an error message
when the script is not found, so users understand what went wrong without turning
on any sort of debugging.

Reported-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 40a6a29..db1d950 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -719,10 +719,29 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
 	}
 
 	if (script_name) {
-		err = scripting_ops->start_script(script_name, argc, argv);
+		char script_exec_path[MAXPATHLEN];
+
+		snprintf(script_exec_path, MAXPATHLEN, "%s", script_name);
+
+		if (access(script_exec_path, R_OK)) {
+
+			snprintf(script_exec_path, MAXPATHLEN, "%s/scripts/%s/%s",
+				 perf_exec_path(), scripting_ops->name, script_name);
+
+			err = access(script_exec_path, R_OK);
+			if (err) {
+				fprintf(stderr, "script %s not found\n", script_name);
+				goto out;
+			}
+		}
+
+		err = scripting_ops->start_script(script_exec_path,
+						  argc, argv);
 		if (err)
 			goto out;
-		pr_debug("perf trace started with script %s\n\n", script_name);
+
+		pr_debug("perf trace started with script %s\n\n",
+			 script_exec_path);
 	}
 
 	err = __cmd_trace(session);
diff --git a/tools/perf/scripts/perl/bin/failed-syscalls-report b/tools/perf/scripts/perl/bin/failed-syscalls-report
index e3a5e55..47cf0b7 100644
--- a/tools/perf/scripts/perl/bin/failed-syscalls-report
+++ b/tools/perf/scripts/perl/bin/failed-syscalls-report
@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/failed-syscalls.pl $comm
+perf trace $@ -s perl/failed-syscalls.pl $comm
diff --git a/tools/perf/scripts/perl/bin/rw-by-file-report b/tools/perf/scripts/perl/bin/rw-by-file-report
index d83070b..407ec70 100644
--- a/tools/perf/scripts/perl/bin/rw-by-file-report
+++ b/tools/perf/scripts/perl/bin/rw-by-file-report
@@ -7,7 +7,7 @@ if [ $# -lt 1 ] ; then
 fi
 comm=$1
 shift
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-file.pl $comm
+perf trace $@ -s perl/rw-by-file.pl $comm
 
 
 
diff --git a/tools/perf/scripts/perl/bin/rw-by-pid-report b/tools/perf/scripts/perl/bin/rw-by-pid-report
index 7ef4698..0c129e1 100644
--- a/tools/perf/scripts/perl/bin/rw-by-pid-report
+++ b/tools/perf/scripts/perl/bin/rw-by-pid-report
@@ -1,6 +1,6 @@
 #!/bin/bash
 # description: system-wide r/w activity
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-pid.pl
+perf trace $@ -s perl/rw-by-pid.pl
 
 
 
diff --git a/tools/perf/scripts/perl/bin/rwtop-report b/tools/perf/scripts/perl/bin/rwtop-report
index 93e698c..5bac5bb 100644
--- a/tools/perf/scripts/perl/bin/rwtop-report
+++ b/tools/perf/scripts/perl/bin/rwtop-report
@@ -17,7 +17,7 @@ if [ "$n_args" -gt 0 ] ; then
     interval=$1
     shift
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rwtop.pl $interval
+perf trace $@ -s perl/rwtop.pl $interval
 
 
 
diff --git a/tools/perf/scripts/perl/bin/wakeup-latency-report b/tools/perf/scripts/perl/bin/wakeup-latency-report
index a0d898f..dcfdd05 100644
--- a/tools/perf/scripts/perl/bin/wakeup-latency-report
+++ b/tools/perf/scripts/perl/bin/wakeup-latency-report
@@ -1,6 +1,6 @@
 #!/bin/bash
 # description: system-wide min/max/avg wakeup latency
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/wakeup-latency.pl
+perf trace $@ -s perl/wakeup-latency.pl
 
 
 
diff --git a/tools/perf/scripts/perl/bin/workqueue-stats-report b/tools/perf/scripts/perl/bin/workqueue-stats-report
index 3508113..6ce9247 100644
--- a/tools/perf/scripts/perl/bin/workqueue-stats-report
+++ b/tools/perf/scripts/perl/bin/workqueue-stats-report
@@ -1,6 +1,6 @@
 #!/bin/bash
 # description: workqueue stats (ins/exe/create/destroy)
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/workqueue-stats.pl
+perf trace $@ -s perl/workqueue-stats.pl
 
 
 
diff --git a/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report b/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report
index 3029354..b39182f 100644
--- a/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report
+++ b/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report
@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/failed-syscalls-by-pid.py $comm
+perf trace $@ -s python/failed-syscalls-by-pid.py $comm
diff --git a/tools/perf/scripts/python/bin/sched-migration-report b/tools/perf/scripts/python/bin/sched-migration-report
index 61d05f7..8299b69 100644
--- a/tools/perf/scripts/python/bin/sched-migration-report
+++ b/tools/perf/scripts/python/bin/sched-migration-report
@@ -1,3 +1,3 @@
 #!/bin/bash
 # description: sched migration overview
-perf trace $@ -s ~/libexec/perf-core/scripts/python/sched-migration.py
+perf trace $@ -s python/sched-migration.py
diff --git a/tools/perf/scripts/python/bin/sctop-report b/tools/perf/scripts/python/bin/sctop-report
index b01c842..9fe812c 100644
--- a/tools/perf/scripts/python/bin/sctop-report
+++ b/tools/perf/scripts/python/bin/sctop-report
@@ -21,4 +21,4 @@ elif [ "$n_args" -gt 0 ] ; then
     interval=$1
     shift
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/sctop.py $comm $interval
+perf trace $@ -s python/sctop.py $comm $interval
diff --git a/tools/perf/scripts/python/bin/syscall-counts-by-pid-report b/tools/perf/scripts/python/bin/syscall-counts-by-pid-report
index 9e9d8dd..ec9d4d9 100644
--- a/tools/perf/scripts/python/bin/syscall-counts-by-pid-report
+++ b/tools/perf/scripts/python/bin/syscall-counts-by-pid-report
@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts-by-pid.py $comm
+perf trace $@ -s python/syscall-counts-by-pid.py $comm
diff --git a/tools/perf/scripts/python/bin/syscall-counts-report b/tools/perf/scripts/python/bin/syscall-counts-report
index dc076b6..9ed7854 100644
--- a/tools/perf/scripts/python/bin/syscall-counts-report
+++ b/tools/perf/scripts/python/bin/syscall-counts-report
@@ -1,3 +1,4 @@
+
 #!/bin/bash
 # description: system-wide syscall counts
 # args: [comm]
@@ -7,4 +8,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts.py $comm
+perf trace $@ -s python/syscall-counts.py $comm
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index b059dc5..97e8c6d 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -557,7 +557,7 @@ static int perl_generate_script(const char *outfile)
 }
 
 struct scripting_ops perl_scripting_ops = {
-	.name = "Perl",
+	.name = "perl",
 	.start_script = perl_start_script,
 	.stop_script = perl_stop_script,
 	.process_event = perl_process_event,
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 33a6325..49655a8 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -586,7 +586,7 @@ static int python_generate_script(const char *outfile)
 }
 
 struct scripting_ops python_scripting_ops = {
-	.name = "Python",
+	.name = "python",
 	.start_script = python_start_script,
 	.stop_script = python_stop_script,
 	.process_event = python_process_event,

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

* Re: [PATCH] perf trace: get rid of the hard-coded paths in the report scripts
  2010-08-13  8:30 ` Stephane Eranian
@ 2010-08-14  4:38   ` Tom Zanussi
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Zanussi @ 2010-08-14  4:38 UTC (permalink / raw)
  To: eranian; +Cc: linux-kernel, acme, mingo, acme, fweisbec, peterz

Hi Stephane,

On Fri, 2010-08-13 at 10:30 +0200, Stephane Eranian wrote:
> Tom,
> 
> Here is version that works for me. Besides the stat() to access() change, I fixed
> the pathname you were building, it was missing the language name. The way I solved
> that is by leveraging the scripting_ops->name field, but for that I had to make sure
> it would match the subdir name, i.e., all lower-case. I also add an error message
> when the script is not found, so users understand what went wrong without turning
> on any sort of debugging.
> 

Hmm, I'm not sure why the previous version didn't work for you, since
that version changed all the scripts to the form:

python/sctop.py

which applied to the format string there, "%s/scripts/%s"

gives

..../scripts/python/sctop.py

so it should have worked.

With your version, I get:

root@tropicana:~# perf trace sctop
script python/sctop.py not found

because the script names still have the form python/sctop.py but are
applied to the new format string "%s/scripts/%s/%s" which gives:

..../scripts/python/python/sctop.py

After removing the python/ prefix from all the scripts, everything works
fine:

root@tropicana:~# perf trace sctop
good output...

root@tropicana:~# perf record -c 1 -e raw_syscalls:sys_enter -a -- sleep
1
[ perf record: Woken up 0 times to write data ]
[ perf record: Captured and wrote 22.546 MB perf.data (~985061
samples) ]
root@tropicana:~# perf trace -g python
generated Python script: perf-trace.py
root@tropicana:~# perf trace -s perf-trace.py > out
good output...

Anyway, for all the reasons you stated and the fact that it gets rid of
everything but the bare script name, I think your version is a nice
improvement - I'll repost it along with the small script changes
mentioned shortly.

Tom



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

* [PATCH] perf trace: get rid of the hard-coded paths in the report scripts
@ 2010-06-18  4:41 Tom Zanussi
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Zanussi @ 2010-06-18  4:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Stephane Eranian, mingo, fweisbec, acme

The perf trace report shell scripts hard-code the exec path of the
scripts into their command-lines, which doesn't work if perf has been
installed somewhere else.

Instead, perf trace should create the paths at run-time.  This patch
does that and removes the hard-coded paths from all the report scripts.

Reported-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
---
 tools/perf/builtin-trace.c                         |   11 +++++++++--
 tools/perf/scripts/perl/bin/failed-syscalls-report |    2 +-
 tools/perf/scripts/perl/bin/rw-by-file-report      |    2 +-
 tools/perf/scripts/perl/bin/rw-by-pid-report       |    2 +-
 tools/perf/scripts/perl/bin/rwtop-report           |    2 +-
 tools/perf/scripts/perl/bin/wakeup-latency-report  |    2 +-
 tools/perf/scripts/perl/bin/workqueue-stats-report |    2 +-
 .../python/bin/failed-syscalls-by-pid-report       |    2 +-
 tools/perf/scripts/python/bin/sctop-report         |    2 +-
 .../python/bin/syscall-counts-by-pid-report        |    2 +-
 .../perf/scripts/python/bin/syscall-counts-report  |    3 ++-
 11 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index dddf3f0..4bb67eb 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -702,10 +702,17 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
 	}
 
 	if (script_name) {
-		err = scripting_ops->start_script(script_name, argc, argv);
+		char script_exec_path[MAXPATHLEN];
+
+		snprintf(script_exec_path, MAXPATHLEN, "%s/scripts/%s",
+			 perf_exec_path(), script_name);
+
+		err = scripting_ops->start_script(script_exec_path,
+						  argc, argv);
 		if (err)
 			goto out;
-		pr_debug("perf trace started with script %s\n\n", script_name);
+		pr_debug("perf trace started with script %s\n\n",
+			 script_exec_path);
 	}
 
 	err = __cmd_trace(session);
diff --git a/tools/perf/scripts/perl/bin/failed-syscalls-report b/tools/perf/scripts/perl/bin/failed-syscalls-report
index e3a5e55..47cf0b7 100644
--- a/tools/perf/scripts/perl/bin/failed-syscalls-report
+++ b/tools/perf/scripts/perl/bin/failed-syscalls-report
@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/failed-syscalls.pl $comm
+perf trace $@ -s perl/failed-syscalls.pl $comm
diff --git a/tools/perf/scripts/perl/bin/rw-by-file-report b/tools/perf/scripts/perl/bin/rw-by-file-report
index d83070b..407ec70 100644
--- a/tools/perf/scripts/perl/bin/rw-by-file-report
+++ b/tools/perf/scripts/perl/bin/rw-by-file-report
@@ -7,7 +7,7 @@ if [ $# -lt 1 ] ; then
 fi
 comm=$1
 shift
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-file.pl $comm
+perf trace $@ -s perl/rw-by-file.pl $comm
 
 
 
diff --git a/tools/perf/scripts/perl/bin/rw-by-pid-report b/tools/perf/scripts/perl/bin/rw-by-pid-report
index 7ef4698..0c129e1 100644
--- a/tools/perf/scripts/perl/bin/rw-by-pid-report
+++ b/tools/perf/scripts/perl/bin/rw-by-pid-report
@@ -1,6 +1,6 @@
 #!/bin/bash
 # description: system-wide r/w activity
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-pid.pl
+perf trace $@ -s perl/rw-by-pid.pl
 
 
 
diff --git a/tools/perf/scripts/perl/bin/rwtop-report b/tools/perf/scripts/perl/bin/rwtop-report
index 93e698c..5bac5bb 100644
--- a/tools/perf/scripts/perl/bin/rwtop-report
+++ b/tools/perf/scripts/perl/bin/rwtop-report
@@ -17,7 +17,7 @@ if [ "$n_args" -gt 0 ] ; then
     interval=$1
     shift
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/rwtop.pl $interval
+perf trace $@ -s perl/rwtop.pl $interval
 
 
 
diff --git a/tools/perf/scripts/perl/bin/wakeup-latency-report b/tools/perf/scripts/perl/bin/wakeup-latency-report
index a0d898f..dcfdd05 100644
--- a/tools/perf/scripts/perl/bin/wakeup-latency-report
+++ b/tools/perf/scripts/perl/bin/wakeup-latency-report
@@ -1,6 +1,6 @@
 #!/bin/bash
 # description: system-wide min/max/avg wakeup latency
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/wakeup-latency.pl
+perf trace $@ -s perl/wakeup-latency.pl
 
 
 
diff --git a/tools/perf/scripts/perl/bin/workqueue-stats-report b/tools/perf/scripts/perl/bin/workqueue-stats-report
index 3508113..6ce9247 100644
--- a/tools/perf/scripts/perl/bin/workqueue-stats-report
+++ b/tools/perf/scripts/perl/bin/workqueue-stats-report
@@ -1,6 +1,6 @@
 #!/bin/bash
 # description: workqueue stats (ins/exe/create/destroy)
-perf trace $@ -s ~/libexec/perf-core/scripts/perl/workqueue-stats.pl
+perf trace $@ -s perl/workqueue-stats.pl
 
 
 
diff --git a/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report b/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report
index 3029354..b39182f 100644
--- a/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report
+++ b/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report
@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/failed-syscalls-by-pid.py $comm
+perf trace $@ -s python/failed-syscalls-by-pid.py $comm
diff --git a/tools/perf/scripts/python/bin/sctop-report b/tools/perf/scripts/python/bin/sctop-report
index b01c842..9fe812c 100644
--- a/tools/perf/scripts/python/bin/sctop-report
+++ b/tools/perf/scripts/python/bin/sctop-report
@@ -21,4 +21,4 @@ elif [ "$n_args" -gt 0 ] ; then
     interval=$1
     shift
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/sctop.py $comm $interval
+perf trace $@ -s python/sctop.py $comm $interval
diff --git a/tools/perf/scripts/python/bin/syscall-counts-by-pid-report b/tools/perf/scripts/python/bin/syscall-counts-by-pid-report
index 9e9d8dd..ec9d4d9 100644
--- a/tools/perf/scripts/python/bin/syscall-counts-by-pid-report
+++ b/tools/perf/scripts/python/bin/syscall-counts-by-pid-report
@@ -7,4 +7,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts-by-pid.py $comm
+perf trace $@ -s python/syscall-counts-by-pid.py $comm
diff --git a/tools/perf/scripts/python/bin/syscall-counts-report b/tools/perf/scripts/python/bin/syscall-counts-report
index dc076b6..9ed7854 100644
--- a/tools/perf/scripts/python/bin/syscall-counts-report
+++ b/tools/perf/scripts/python/bin/syscall-counts-report
@@ -1,3 +1,4 @@
+
 #!/bin/bash
 # description: system-wide syscall counts
 # args: [comm]
@@ -7,4 +8,4 @@ if [ $# -gt 0 ] ; then
 	shift
     fi
 fi
-perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts.py $comm
+perf trace $@ -s python/syscall-counts.py $comm
-- 
1.6.4.GIT




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

end of thread, other threads:[~2010-08-14  4:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-12 17:59 [PATCH] perf trace: get rid of the hard-coded paths in the report scripts Tom Zanussi
2010-08-12 18:20 ` Arnaldo Carvalho de Melo
2010-08-12 21:29   ` Stephane Eranian
2010-08-12 21:28 ` Stephane Eranian
2010-08-12 21:50   ` Tom Zanussi
2010-08-13  8:30 ` Stephane Eranian
2010-08-14  4:38   ` Tom Zanussi
  -- strict thread matches above, loose matches on Subject: below --
2010-06-18  4:41 Tom Zanussi

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.