linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] perf stat cleanups
@ 2013-09-28 20:27 David Ahern
  2013-09-28 20:27 ` [PATCH 1/3] perf stat: Fix misleading message when specifying cpu list or system wide David Ahern
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: David Ahern @ 2013-09-28 20:27 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: David Ahern

Arnaldo:

A few perf-stat cleanups.

David Ahern (3):
  perf stat: Fix misleading message when specifying cpu list or system wide
  perf stat: Don't require a workload when using system wide or CPU options
  perf stat: Add units to nanosec-based counters

 tools/perf/builtin-stat.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

-- 
1.7.10.1


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

* [PATCH 1/3] perf stat: Fix misleading message when specifying cpu list or system wide
  2013-09-28 20:27 [PATCH 0/3] perf stat cleanups David Ahern
@ 2013-09-28 20:27 ` David Ahern
  2013-10-15  5:29   ` [tip:perf/core] " tip-bot for David Ahern
  2013-09-28 20:27 ` [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options David Ahern
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: David Ahern @ 2013-09-28 20:27 UTC (permalink / raw)
  To: acme, linux-kernel
  Cc: David Ahern, Ingo Molnar, Frederic Weisbecker, Peter Zijlstra,
	Jiri Olsa, Namhyung Kim, Stephane Eranian

perf-stat displays the command run in its summary output which is misleading
when using a cpu list or system wide collection.

Before:

perf stat -a -- sleep 1

 Performance counter stats for 'sleep 1':

16152.670249 task-clock                #   16.132 CPUs utilized
         417 context-switches          #    0.002 M/sec
           7 cpu-migrations            #    0.030 K/sec
...

After:

perf stat -a -- sleep 1

 Performance counter stats for 'system wide':

16206.931120 task-clock                #   16.144 CPUs utilized
         395 context-switches          #    0.002 M/sec
           5 cpu-migrations            #    0.030 K/sec
...

or

perf stat -C1 -- sleep 1

 Performance counter stats for 'CPU(s) 1':

   1001.669257 task-clock                #    1.000 CPUs utilized
         4,264 context-switches          #    0.004 M/sec
             3 cpu-migrations            #    0.003 K/sec
...

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/builtin-stat.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index f686d5f..6cc0aa2 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1115,7 +1115,11 @@ static void print_stat(int argc, const char **argv)
 	if (!csv_output) {
 		fprintf(output, "\n");
 		fprintf(output, " Performance counter stats for ");
-		if (!perf_target__has_task(&target)) {
+		if (target.system_wide)
+			fprintf(output, "\'system wide");
+		else if (target.cpu_list)
+			fprintf(output, "\'CPU(s) %s", target.cpu_list);
+		else if (!perf_target__has_task(&target)) {
 			fprintf(output, "\'%s", argv[0]);
 			for (i = 1; i < argc; i++)
 				fprintf(output, " %s", argv[i]);
-- 
1.7.10.1


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

* [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options
  2013-09-28 20:27 [PATCH 0/3] perf stat cleanups David Ahern
  2013-09-28 20:27 ` [PATCH 1/3] perf stat: Fix misleading message when specifying cpu list or system wide David Ahern
@ 2013-09-28 20:27 ` David Ahern
  2013-09-30  8:47   ` Namhyung Kim
  2013-09-28 20:28 ` [PATCH 3/3] perf stat: Add units to nanosec-based counters David Ahern
  2013-10-08  1:44 ` [PATCH 0/3] perf stat cleanups David Ahern
  3 siblings, 1 reply; 17+ messages in thread
From: David Ahern @ 2013-09-28 20:27 UTC (permalink / raw)
  To: acme, linux-kernel
  Cc: David Ahern, Ingo Molnar, Frederic Weisbecker, Peter Zijlstra,
	Jiri Olsa, Namhyung Kim, Stephane Eranian

perf-stat can do system wide counters or one or more cpus. For
these options do not require a workload to be specified.

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/builtin-stat.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 6cc0aa2..60239fe 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1517,8 +1517,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 	} else if (big_num_opt == 0) /* User passed --no-big-num */
 		big_num = false;
 
-	if (!argc && !perf_target__has_task(&target))
+	if (!argc && !perf_target__has_task(&target) &&
+	    !perf_target__has_cpu(&target))
 		usage_with_options(stat_usage, options);
+
 	if (run_count < 0) {
 		usage_with_options(stat_usage, options);
 	} else if (run_count == 0) {
-- 
1.7.10.1


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

* [PATCH 3/3] perf stat: Add units to nanosec-based counters
  2013-09-28 20:27 [PATCH 0/3] perf stat cleanups David Ahern
  2013-09-28 20:27 ` [PATCH 1/3] perf stat: Fix misleading message when specifying cpu list or system wide David Ahern
  2013-09-28 20:27 ` [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options David Ahern
@ 2013-09-28 20:28 ` David Ahern
  2013-10-15  5:30   ` [tip:perf/core] " tip-bot for David Ahern
  2013-10-08  1:44 ` [PATCH 0/3] perf stat cleanups David Ahern
  3 siblings, 1 reply; 17+ messages in thread
From: David Ahern @ 2013-09-28 20:28 UTC (permalink / raw)
  To: acme, linux-kernel
  Cc: David Ahern, Ingo Molnar, Frederic Weisbecker, Peter Zijlstra,
	Jiri Olsa, Namhyung Kim, Stephane Eranian

Ingo pointed out that the task-clock counter should have the units explicitly
stated since it is not a counter.

Before:

perf stat -a -- sleep 1

 Performance counter stats for 'sleep 1':

      16186.874834 task-clock          #   16.154 CPUs utilized
...

After:

perf stat -a -- sleep 1

 Performance counter stats for 'system wide':

      16146.402138 task-clock (msec)   #   16.125 CPUs utilized
...

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/builtin-stat.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 60239fe..746a6db 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -628,10 +628,13 @@ static void nsec_printout(int cpu, int nr, struct perf_evsel *evsel, double avg)
 {
 	double msecs = avg / 1e6;
 	const char *fmt = csv_output ? "%.6f%s%s" : "%18.6f%s%-25s";
+	char name[25];
 
 	aggr_printout(evsel, cpu, nr);
 
-	fprintf(output, fmt, msecs, csv_sep, perf_evsel__name(evsel));
+	scnprintf(name, sizeof(name), "%s%s",
+		  perf_evsel__name(evsel), csv_output ? "" : " (msec)");
+	fprintf(output, fmt, msecs, csv_sep, name);
 
 	if (evsel->cgrp)
 		fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
-- 
1.7.10.1


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

* Re: [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options
  2013-09-28 20:27 ` [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options David Ahern
@ 2013-09-30  8:47   ` Namhyung Kim
  2013-09-30 13:40     ` David Ahern
  0 siblings, 1 reply; 17+ messages in thread
From: Namhyung Kim @ 2013-09-30  8:47 UTC (permalink / raw)
  To: David Ahern
  Cc: acme, linux-kernel, Ingo Molnar, Frederic Weisbecker,
	Peter Zijlstra, Jiri Olsa, Namhyung Kim, Stephane Eranian

Hi David,

On Sat, 28 Sep 2013 14:27:59 -0600, David Ahern wrote:
> perf-stat can do system wide counters or one or more cpus. For
> these options do not require a workload to be specified.
>
> Signed-off-by: David Ahern <dsahern@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Namhyung Kim <namhyung.kim@lge.com>
> Cc: Stephane Eranian <eranian@google.com>
> ---
>  tools/perf/builtin-stat.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 6cc0aa2..60239fe 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -1517,8 +1517,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
>  	} else if (big_num_opt == 0) /* User passed --no-big-num */
>  		big_num = false;
>  
> -	if (!argc && !perf_target__has_task(&target))
> +	if (!argc && !perf_target__has_task(&target) &&
> +	    !perf_target__has_cpu(&target))

You can use perf_target__none() for this.

Btw I found a bug in setting child_pid (which introduced by me ;) during
this review.  Will send a fix.

Thanks,
Namhyung


>  		usage_with_options(stat_usage, options);
> +
>  	if (run_count < 0) {
>  		usage_with_options(stat_usage, options);
>  	} else if (run_count == 0) {

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

* Re: [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options
  2013-09-30  8:47   ` Namhyung Kim
@ 2013-09-30 13:40     ` David Ahern
  2013-10-08 12:39       ` Arnaldo Carvalho de Melo
  2013-10-15  5:30       ` [tip:perf/core] perf stat: Don' t " tip-bot for David Ahern
  0 siblings, 2 replies; 17+ messages in thread
From: David Ahern @ 2013-09-30 13:40 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: acme, linux-kernel, Ingo Molnar, Frederic Weisbecker,
	Peter Zijlstra, Jiri Olsa, Namhyung Kim, Stephane Eranian,
	David (me)

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

On 9/30/13 2:47 AM, Namhyung Kim wrote:
>> @@ -1517,8 +1517,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
>>   	} else if (big_num_opt == 0) /* User passed --no-big-num */
>>   		big_num = false;
>>
>> -	if (!argc && !perf_target__has_task(&target))
>> +	if (!argc && !perf_target__has_task(&target) &&
>> +	    !perf_target__has_cpu(&target))
>
> You can use perf_target__none() for this.

Indeed. Updated patch attached.

David


[-- Attachment #2: 0002-perf-stat-Don-t-require-a-workload-when-using-system.patch --]
[-- Type: text/plain, Size: 1385 bytes --]

>From a7018902283b3cfc5cae8a1876e2c14f3c7c9c7e Mon Sep 17 00:00:00 2001
From: David Ahern <dsahern@gmail.com>
Date: Mon, 30 Sep 2013 07:37:37 -0600
Subject: [PATCH] perf stat: Don't require a workload when using system wide or CPU options -v2

perf-stat can do system wide counters or one or more cpus. For
these options do not require a workload to be specified.

v2: use perf_target__none per Namhyung's comment

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/builtin-stat.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 6cc0aa2..db55b91 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1517,8 +1517,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 	} else if (big_num_opt == 0) /* User passed --no-big-num */
 		big_num = false;
 
-	if (!argc && !perf_target__has_task(&target))
+	if (!argc && perf_target__none(&target))
 		usage_with_options(stat_usage, options);
+
 	if (run_count < 0) {
 		usage_with_options(stat_usage, options);
 	} else if (run_count == 0) {
-- 
1.7.10.1


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

* Re: [PATCH 0/3] perf stat cleanups
  2013-09-28 20:27 [PATCH 0/3] perf stat cleanups David Ahern
                   ` (2 preceding siblings ...)
  2013-09-28 20:28 ` [PATCH 3/3] perf stat: Add units to nanosec-based counters David Ahern
@ 2013-10-08  1:44 ` David Ahern
  3 siblings, 0 replies; 17+ messages in thread
From: David Ahern @ 2013-10-08  1:44 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel

ping

On 9/28/13 2:27 PM, David Ahern wrote:
> Arnaldo:
>
> A few perf-stat cleanups.
>
> David Ahern (3):
>    perf stat: Fix misleading message when specifying cpu list or system wide
>    perf stat: Don't require a workload when using system wide or CPU options
>    perf stat: Add units to nanosec-based counters
>
>   tools/perf/builtin-stat.c |   15 ++++++++++++---
>   1 file changed, 12 insertions(+), 3 deletions(-)
>


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

* Re: [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options
  2013-09-30 13:40     ` David Ahern
@ 2013-10-08 12:39       ` Arnaldo Carvalho de Melo
  2013-10-08 12:51         ` Ingo Molnar
  2013-10-08 13:25         ` David Ahern
  2013-10-15  5:30       ` [tip:perf/core] perf stat: Don' t " tip-bot for David Ahern
  1 sibling, 2 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-10-08 12:39 UTC (permalink / raw)
  To: David Ahern
  Cc: Namhyung Kim, linux-kernel, Ingo Molnar, Frederic Weisbecker,
	Peter Zijlstra, Jiri Olsa, Namhyung Kim, Stephane Eranian

Em Mon, Sep 30, 2013 at 07:40:12AM -0600, David Ahern escreveu:
> On 9/30/13 2:47 AM, Namhyung Kim wrote:
> >>@@ -1517,8 +1517,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
> >>  	} else if (big_num_opt == 0) /* User passed --no-big-num */
> >>  		big_num = false;
> >>
> >>-	if (!argc && !perf_target__has_task(&target))
> >>+	if (!argc && !perf_target__has_task(&target) &&
> >>+	    !perf_target__has_cpu(&target))
> >
> >You can use perf_target__none() for this.
> 
> Indeed. Updated patch attached.

Cool patch, applying to acme/perf/core.

While trying it noticed this, that should also be fixed
eventually:

[root@zoo ~]# perf stat -c C 0
C: No such file or directory

 Performance counter stats for 'C 0':

     <not counted> task-clock              
     <not counted> context-switches        
     <not counted> cpu-migrations 
<SNIP>

- Arnaldo

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

* Re: [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options
  2013-10-08 12:39       ` Arnaldo Carvalho de Melo
@ 2013-10-08 12:51         ` Ingo Molnar
  2013-10-08 13:27           ` Arnaldo Carvalho de Melo
  2013-10-08 13:25         ` David Ahern
  1 sibling, 1 reply; 17+ messages in thread
From: Ingo Molnar @ 2013-10-08 12:51 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: David Ahern, Namhyung Kim, linux-kernel, Frederic Weisbecker,
	Peter Zijlstra, Jiri Olsa, Namhyung Kim, Stephane Eranian


* Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:

> Em Mon, Sep 30, 2013 at 07:40:12AM -0600, David Ahern escreveu:
> > On 9/30/13 2:47 AM, Namhyung Kim wrote:
> > >>@@ -1517,8 +1517,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
> > >>  	} else if (big_num_opt == 0) /* User passed --no-big-num */
> > >>  		big_num = false;
> > >>
> > >>-	if (!argc && !perf_target__has_task(&target))
> > >>+	if (!argc && !perf_target__has_task(&target) &&
> > >>+	    !perf_target__has_cpu(&target))
> > >
> > >You can use perf_target__none() for this.
> > 
> > Indeed. Updated patch attached.
> 
> Cool patch, applying to acme/perf/core.
> 
> While trying it noticed this, that should also be fixed
> eventually:
> 
> [root@zoo ~]# perf stat -c C 0
> C: No such file or directory
> 
>  Performance counter stats for 'C 0':
> 
>      <not counted> task-clock              
>      <not counted> context-switches        
>      <not counted> cpu-migrations 
> <SNIP>

Btw., would anyone be interested in adding CPU and node binding options to 
perf stat?

There's code to do something like that in tools/perf/bench/numa.c:

        /* Special option string parsing callbacks: */
        OPT_CALLBACK('C', "cpus", NULL, "cpu[,cpu2,...cpuN]",
                        "bind the first N tasks to these specific cpus (the rest is unbound)",
                        parse_cpus_opt),
        OPT_CALLBACK('M', "memnodes", NULL, "node[,node2,...nodeN]",
                        "bind the first N tasks to these specific memory nodes (the rest is unbound)",
                        parse_nodes_opt),

Thanks,

	Ingo

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

* Re: [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options
  2013-10-08 12:39       ` Arnaldo Carvalho de Melo
  2013-10-08 12:51         ` Ingo Molnar
@ 2013-10-08 13:25         ` David Ahern
  2013-10-08 13:33           ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 17+ messages in thread
From: David Ahern @ 2013-10-08 13:25 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, linux-kernel, Ingo Molnar, Frederic Weisbecker,
	Peter Zijlstra, Jiri Olsa, Namhyung Kim, Stephane Eranian

On 10/8/13 6:39 AM, Arnaldo Carvalho de Melo wrote:
> While trying it noticed this, that should also be fixed
> eventually:
>
> [root@zoo ~]# perf stat -c C 0
> C: No such file or directory

you are missing '-' before the C:  perf stat -C 0. The -C = cpus. -c for 
stat is scale.

David

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

* Re: [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options
  2013-10-08 12:51         ` Ingo Molnar
@ 2013-10-08 13:27           ` Arnaldo Carvalho de Melo
  2013-10-08 19:24             ` Ingo Molnar
  0 siblings, 1 reply; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-10-08 13:27 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: David Ahern, Namhyung Kim, linux-kernel, Frederic Weisbecker,
	Peter Zijlstra, Jiri Olsa, Namhyung Kim, Stephane Eranian

Em Tue, Oct 08, 2013 at 02:51:13PM +0200, Ingo Molnar escreveu:
> Btw., would anyone be interested in adding CPU and node binding options to 
> perf stat?
> 
> There's code to do something like that in tools/perf/bench/numa.c:
> 
>         /* Special option string parsing callbacks: */
>         OPT_CALLBACK('C', "cpus", NULL, "cpu[,cpu2,...cpuN]",
>                         "bind the first N tasks to these specific cpus (the rest is unbound)",
>                         parse_cpus_opt),
>         OPT_CALLBACK('M', "memnodes", NULL, "node[,node2,...nodeN]",
>                         "bind the first N tasks to these specific memory nodes (the rest is unbound)",
>                         parse_nodes_opt),

As a convenience to using:

	taskset -c cpu-list perf stat -C cpu-list workload

?

- Arnaldo

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

* Re: [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options
  2013-10-08 13:25         ` David Ahern
@ 2013-10-08 13:33           ` Arnaldo Carvalho de Melo
  2013-10-08 13:42             ` David Ahern
  0 siblings, 1 reply; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-10-08 13:33 UTC (permalink / raw)
  To: David Ahern
  Cc: Namhyung Kim, linux-kernel, Ingo Molnar, Frederic Weisbecker,
	Peter Zijlstra, Jiri Olsa, Namhyung Kim, Stephane Eranian

Em Tue, Oct 08, 2013 at 07:25:39AM -0600, David Ahern escreveu:
> On 10/8/13 6:39 AM, Arnaldo Carvalho de Melo wrote:
> >While trying it noticed this, that should also be fixed
> >eventually:

> >[root@zoo ~]# perf stat -c C 0
> >C: No such file or directory
 
> you are missing '-' before the C:  perf stat -C 0. The -C = cpus. -c
> for stat is scale.

Nah, I mean:

[acme@zoo linux]$ perf stat non-existent-proggie
non-existent-proggie: No such file or directory

 Performance counter stats for 'non-existent-proggie':

     <not counted> task-clock              
     <not counted> context-switches        
     <not counted> cpu-migrations          
     <not counted> page-faults             
     <not counted> cycles                  
     <not counted> stalled-cycles-frontend 
   <not supported> stalled-cycles-backend  
     <not counted> instructions            
     <not counted> branches                
     <not counted> branch-misses           

       0.001823577 seconds time elapsed

[acme@zoo linux]$

Why should we report all those counters for something that wasn't found
in PATH?

We either report just the first line, with the errno, or that and the
last, with how long it took to try to execute it, but that probably
shouldn't be printed, as it is supposed to be how long the workload ran,
right?

- Arnaldo

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

* Re: [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options
  2013-10-08 13:33           ` Arnaldo Carvalho de Melo
@ 2013-10-08 13:42             ` David Ahern
  0 siblings, 0 replies; 17+ messages in thread
From: David Ahern @ 2013-10-08 13:42 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, linux-kernel, Ingo Molnar, Frederic Weisbecker,
	Peter Zijlstra, Jiri Olsa, Namhyung Kim, Stephane Eranian

On 10/8/13 7:33 AM, Arnaldo Carvalho de Melo wrote:
> [acme@zoo linux]$ perf stat non-existent-proggie
> non-existent-proggie: No such file or directory

ok. so this is a different error. need to detect the workload does not 
exist.

> Why should we report all those counters for something that wasn't found
> in PATH?
>
> We either report just the first line, with the errno, or that and the
> last, with how long it took to try to execute it, but that probably
> shouldn't be printed, as it is supposed to be how long the workload ran,
> right?

Right. need to feed/detect the exec failure back to the parent.

David

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

* Re: [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options
  2013-10-08 13:27           ` Arnaldo Carvalho de Melo
@ 2013-10-08 19:24             ` Ingo Molnar
  0 siblings, 0 replies; 17+ messages in thread
From: Ingo Molnar @ 2013-10-08 19:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: David Ahern, Namhyung Kim, linux-kernel, Frederic Weisbecker,
	Peter Zijlstra, Jiri Olsa, Namhyung Kim, Stephane Eranian


* Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:

> Em Tue, Oct 08, 2013 at 02:51:13PM +0200, Ingo Molnar escreveu:
> > Btw., would anyone be interested in adding CPU and node binding options to 
> > perf stat?
> > 
> > There's code to do something like that in tools/perf/bench/numa.c:
> > 
> >         /* Special option string parsing callbacks: */
> >         OPT_CALLBACK('C', "cpus", NULL, "cpu[,cpu2,...cpuN]",
> >                         "bind the first N tasks to these specific cpus (the rest is unbound)",
> >                         parse_cpus_opt),
> >         OPT_CALLBACK('M', "memnodes", NULL, "node[,node2,...nodeN]",
> >                         "bind the first N tasks to these specific memory nodes (the rest is unbound)",
> >                         parse_nodes_opt),
> 
> As a convenience to using:
> 
> 	taskset -c cpu-list perf stat -C cpu-list workload
> 
> ?

Yeah, something like that would be handy I think.

	Ingo

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

* [tip:perf/core] perf stat: Fix misleading message when specifying cpu list or system wide
  2013-09-28 20:27 ` [PATCH 1/3] perf stat: Fix misleading message when specifying cpu list or system wide David Ahern
@ 2013-10-15  5:29   ` tip-bot for David Ahern
  0 siblings, 0 replies; 17+ messages in thread
From: tip-bot for David Ahern @ 2013-10-15  5:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, hpa, mingo, a.p.zijlstra,
	namhyung.kim, jolsa, fweisbec, dsahern, tglx

Commit-ID:  62d3b617c02785a4f1fbde8d93ca77a0b33d8454
Gitweb:     http://git.kernel.org/tip/62d3b617c02785a4f1fbde8d93ca77a0b33d8454
Author:     David Ahern <dsahern@gmail.com>
AuthorDate: Sat, 28 Sep 2013 14:27:58 -0600
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 11 Oct 2013 12:17:42 -0300

perf stat: Fix misleading message when specifying cpu list or system wide

The "perf stat" tool displays the command run in its summary output
which is misleading when using a cpu list or system wide collection.

Before:

perf stat -a -- sleep 1

 Performance counter stats for 'sleep 1':

16152.670249 task-clock                #   16.132 CPUs utilized
         417 context-switches          #    0.002 M/sec
           7 cpu-migrations            #    0.030 K/sec
...

After:

perf stat -a -- sleep 1

 Performance counter stats for 'system wide':

16206.931120 task-clock                #   16.144 CPUs utilized
         395 context-switches          #    0.002 M/sec
           5 cpu-migrations            #    0.030 K/sec
...

or

perf stat -C1 -- sleep 1

 Performance counter stats for 'CPU(s) 1':

   1001.669257 task-clock                #    1.000 CPUs utilized
         4,264 context-switches          #    0.004 M/sec
             3 cpu-migrations            #    0.003 K/sec
...

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1380400080-9211-2-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index fb02b53..c8a2662 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1229,7 +1229,11 @@ static void print_stat(int argc, const char **argv)
 	if (!csv_output) {
 		fprintf(output, "\n");
 		fprintf(output, " Performance counter stats for ");
-		if (!perf_target__has_task(&target)) {
+		if (target.system_wide)
+			fprintf(output, "\'system wide");
+		else if (target.cpu_list)
+			fprintf(output, "\'CPU(s) %s", target.cpu_list);
+		else if (!perf_target__has_task(&target)) {
 			fprintf(output, "\'%s", argv[0]);
 			for (i = 1; i < argc; i++)
 				fprintf(output, " %s", argv[i]);

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

* [tip:perf/core] perf stat: Don' t require a workload when using system wide or CPU options
  2013-09-30 13:40     ` David Ahern
  2013-10-08 12:39       ` Arnaldo Carvalho de Melo
@ 2013-10-15  5:30       ` tip-bot for David Ahern
  1 sibling, 0 replies; 17+ messages in thread
From: tip-bot for David Ahern @ 2013-10-15  5:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, hpa, mingo, a.p.zijlstra,
	namhyung.kim, jolsa, fweisbec, dsahern, tglx

Commit-ID:  ac3063bd4725689f39d7a23fdfca2e034c73dcac
Gitweb:     http://git.kernel.org/tip/ac3063bd4725689f39d7a23fdfca2e034c73dcac
Author:     David Ahern <dsahern@gmail.com>
AuthorDate: Mon, 30 Sep 2013 07:37:37 -0600
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 11 Oct 2013 12:17:44 -0300

perf stat: Don't require a workload when using system wide or CPU options

The "perf stat" command can do system wide counters or one or more cpus.
For these options do not require a workload to be specified.

v2: use perf_target__none per Namhyung's comment.

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/52497F3C.9070908@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index c8a2662..2178e66 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1659,8 +1659,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 	} else if (big_num_opt == 0) /* User passed --no-big-num */
 		big_num = false;
 
-	if (!argc && !perf_target__has_task(&target))
+	if (!argc && perf_target__none(&target))
 		usage_with_options(stat_usage, options);
+
 	if (run_count < 0) {
 		usage_with_options(stat_usage, options);
 	} else if (run_count == 0) {

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

* [tip:perf/core] perf stat: Add units to nanosec-based counters
  2013-09-28 20:28 ` [PATCH 3/3] perf stat: Add units to nanosec-based counters David Ahern
@ 2013-10-15  5:30   ` tip-bot for David Ahern
  0 siblings, 0 replies; 17+ messages in thread
From: tip-bot for David Ahern @ 2013-10-15  5:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, eranian, hpa, mingo, a.p.zijlstra,
	namhyung.kim, jolsa, fweisbec, dsahern, tglx

Commit-ID:  4bbe5a61f29b13437a6a16467328d3bae8fce9e7
Gitweb:     http://git.kernel.org/tip/4bbe5a61f29b13437a6a16467328d3bae8fce9e7
Author:     David Ahern <dsahern@gmail.com>
AuthorDate: Sat, 28 Sep 2013 14:28:00 -0600
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 11 Oct 2013 12:17:46 -0300

perf stat: Add units to nanosec-based counters

Ingo pointed out that the task-clock counter should have the units
explicitly stated since it is not a counter.

Before:

perf stat -a -- sleep 1

 Performance counter stats for 'sleep 1':

      16186.874834 task-clock          #   16.154 CPUs utilized
...

After:

perf stat -a -- sleep 1

 Performance counter stats for 'system wide':

      16146.402138 task-clock (msec)   #   16.125 CPUs utilized
...

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1380400080-9211-4-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 2178e66..1a9c95d 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -706,10 +706,13 @@ static void nsec_printout(int cpu, int nr, struct perf_evsel *evsel, double avg)
 {
 	double msecs = avg / 1e6;
 	const char *fmt = csv_output ? "%.6f%s%s" : "%18.6f%s%-25s";
+	char name[25];
 
 	aggr_printout(evsel, cpu, nr);
 
-	fprintf(output, fmt, msecs, csv_sep, perf_evsel__name(evsel));
+	scnprintf(name, sizeof(name), "%s%s",
+		  perf_evsel__name(evsel), csv_output ? "" : " (msec)");
+	fprintf(output, fmt, msecs, csv_sep, name);
 
 	if (evsel->cgrp)
 		fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);

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

end of thread, other threads:[~2013-10-15  5:40 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-28 20:27 [PATCH 0/3] perf stat cleanups David Ahern
2013-09-28 20:27 ` [PATCH 1/3] perf stat: Fix misleading message when specifying cpu list or system wide David Ahern
2013-10-15  5:29   ` [tip:perf/core] " tip-bot for David Ahern
2013-09-28 20:27 ` [PATCH 2/3] perf stat: Don't require a workload when using system wide or CPU options David Ahern
2013-09-30  8:47   ` Namhyung Kim
2013-09-30 13:40     ` David Ahern
2013-10-08 12:39       ` Arnaldo Carvalho de Melo
2013-10-08 12:51         ` Ingo Molnar
2013-10-08 13:27           ` Arnaldo Carvalho de Melo
2013-10-08 19:24             ` Ingo Molnar
2013-10-08 13:25         ` David Ahern
2013-10-08 13:33           ` Arnaldo Carvalho de Melo
2013-10-08 13:42             ` David Ahern
2013-10-15  5:30       ` [tip:perf/core] perf stat: Don' t " tip-bot for David Ahern
2013-09-28 20:28 ` [PATCH 3/3] perf stat: Add units to nanosec-based counters David Ahern
2013-10-15  5:30   ` [tip:perf/core] " tip-bot for David Ahern
2013-10-08  1:44 ` [PATCH 0/3] perf stat cleanups David Ahern

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