All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] perf tools: Fix -C option for record command
@ 2013-02-25  9:52 Jiri Olsa
  2013-02-25  9:52 ` [PATCH 1/5] " Jiri Olsa
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Jiri Olsa @ 2013-02-25  9:52 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Paul Mackerras, Corey Ashford, Frederic Weisbecker, Namhyung Kim,
	David Ahern, Oleg Nesterov

hi,
Oleg reported the -C option in record not work properly:
http://marc.info/?l=linux-kernel&m=136017986313315&w=2

The issue seems to be that the '-C X' target is considered
as task related when it comes to synthetizing threads. Adding
the fix plus some automated test cases.

Available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/linux.git
perf/oleg1

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: David Ahern <dsahern@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
---
Jiri Olsa (5):
      perf tools: Fix -C option for record command
      perf tests: Make attr script verbose friendly
      perf tests: Make attr script test event cpu
      perf tests: Add attr record -C cpu test
      perf tests: Add attr stat -C cpu test

 tools/perf/builtin-record.c          |  6 ++++--
 tools/perf/tests/attr.c              |  9 +++++++--
 tools/perf/tests/attr.py             |  5 +++--
 tools/perf/tests/attr/base-record    |  1 +
 tools/perf/tests/attr/base-stat      |  1 +
 tools/perf/tests/attr/test-record-C0 | 13 +++++++++++++
 tools/perf/tests/attr/test-stat-C0   |  9 +++++++++
 7 files changed, 38 insertions(+), 6 deletions(-)
 create mode 100644 tools/perf/tests/attr/test-record-C0
 create mode 100644 tools/perf/tests/attr/test-stat-C0

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

* [PATCH 1/5] perf tools: Fix -C option for record command
  2013-02-25  9:52 [PATCH 0/5] perf tools: Fix -C option for record command Jiri Olsa
@ 2013-02-25  9:52 ` Jiri Olsa
  2013-02-25 18:39   ` Oleg Nesterov
  2013-03-18 10:53   ` [tip:perf/urgent] perf record: Fix -C option tip-bot for Jiri Olsa
  2013-02-25  9:52 ` [PATCH 2/5] perf tests: Make attr script verbose friendly Jiri Olsa
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 15+ messages in thread
From: Jiri Olsa @ 2013-02-25  9:52 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,
	David Ahern, Oleg Nesterov

Currently the -C option does not work for record command,
because of the targets mismatch when synthesizing threads.

Fixing this by using proper target interface for the
synthesize decision.

Reported-by: Oleg Nesterov <oleg@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: David Ahern <dsahern@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
---
 tools/perf/builtin-record.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 774c907..f1a939e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -573,13 +573,15 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
 					 perf_event__synthesize_guest_os, tool);
 	}
 
-	if (!opts->target.system_wide)
+	if (perf_target__has_task(&opts->target))
 		err = perf_event__synthesize_thread_map(tool, evsel_list->threads,
 						  process_synthesized_event,
 						  machine);
-	else
+	else if (perf_target__has_cpu(&opts->target))
 		err = perf_event__synthesize_threads(tool, process_synthesized_event,
 					       machine);
+	else /* command specified */
+		err = 0;
 
 	if (err != 0)
 		goto out_delete_session;
-- 
1.7.11.7


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

* [PATCH 2/5] perf tests: Make attr script verbose friendly
  2013-02-25  9:52 [PATCH 0/5] perf tools: Fix -C option for record command Jiri Olsa
  2013-02-25  9:52 ` [PATCH 1/5] " Jiri Olsa
@ 2013-02-25  9:52 ` Jiri Olsa
  2013-03-21 10:54   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2013-02-25  9:52 ` [PATCH 3/5] perf tests: Make attr script test event cpu Jiri Olsa
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Jiri Olsa @ 2013-02-25  9:52 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,
	David Ahern, Oleg Nesterov

Making the attr test script runner to pass proper
verbose option. Also making single '-v' be more
reader friendly and display just the test name.

Making the current output to be display for '-vv'.

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: David Ahern <dsahern@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
---
 tools/perf/tests/attr.c  | 9 +++++++--
 tools/perf/tests/attr.py | 4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index bdcceb8..038de3e 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -147,10 +147,15 @@ void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
 
 static int run_dir(const char *d, const char *perf)
 {
+	char v[] = "-vvvvv";
+	int vcnt = min(verbose, (int) sizeof(v) - 1);
 	char cmd[3*PATH_MAX];
 
-	snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %s",
-		 d, d, perf, verbose ? "-v" : "");
+	if (verbose)
+		vcnt++;
+
+	snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
+		 d, d, perf, vcnt, v);
 
 	return system(cmd);
 }
diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py
index 2f629ca..e0ea513 100644
--- a/tools/perf/tests/attr.py
+++ b/tools/perf/tests/attr.py
@@ -121,7 +121,7 @@ class Test(object):
         parser = ConfigParser.SafeConfigParser()
         parser.read(path)
 
-        log.debug("running '%s'" % path)
+        log.warning("running '%s'" % path)
 
         self.path     = path
         self.test_dir = options.test_dir
@@ -172,7 +172,7 @@ class Test(object):
               self.perf, self.command, tempdir, self.args)
         ret = os.WEXITSTATUS(os.system(cmd))
 
-        log.warning("  running '%s' ret %d " % (cmd, ret))
+        log.info("  '%s' ret %d " % (cmd, ret))
 
         if ret != int(self.ret):
             raise Unsup(self)
-- 
1.7.11.7


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

* [PATCH 3/5] perf tests: Make attr script test event cpu
  2013-02-25  9:52 [PATCH 0/5] perf tools: Fix -C option for record command Jiri Olsa
  2013-02-25  9:52 ` [PATCH 1/5] " Jiri Olsa
  2013-02-25  9:52 ` [PATCH 2/5] perf tests: Make attr script verbose friendly Jiri Olsa
@ 2013-02-25  9:52 ` Jiri Olsa
  2013-03-21 10:55   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2013-02-25  9:52 ` [PATCH 4/5] perf tests: Add attr record -C cpu test Jiri Olsa
  2013-02-25  9:52 ` [PATCH 5/5] perf tests: Add attr stat " Jiri Olsa
  4 siblings, 1 reply; 15+ messages in thread
From: Jiri Olsa @ 2013-02-25  9:52 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,
	David Ahern, Oleg Nesterov

Make attr script to check for 'cpu' when testing
event properties. This will allow us to check the
'-C X' option for both record and stat commands.

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: David Ahern <dsahern@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
---
 tools/perf/tests/attr.py          | 1 +
 tools/perf/tests/attr/base-record | 1 +
 tools/perf/tests/attr/base-stat   | 1 +
 3 files changed, 3 insertions(+)

diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py
index e0ea513..c9b4b62 100644
--- a/tools/perf/tests/attr.py
+++ b/tools/perf/tests/attr.py
@@ -24,6 +24,7 @@ class Unsup(Exception):
 
 class Event(dict):
     terms = [
+        'cpu',
         'flags',
         'type',
         'size',
diff --git a/tools/perf/tests/attr/base-record b/tools/perf/tests/attr/base-record
index 5bc3880..b4fc835 100644
--- a/tools/perf/tests/attr/base-record
+++ b/tools/perf/tests/attr/base-record
@@ -2,6 +2,7 @@
 fd=1
 group_fd=-1
 flags=0
+cpu=*
 type=0|1
 size=96
 config=0
diff --git a/tools/perf/tests/attr/base-stat b/tools/perf/tests/attr/base-stat
index 4bd79a8..748ee94 100644
--- a/tools/perf/tests/attr/base-stat
+++ b/tools/perf/tests/attr/base-stat
@@ -2,6 +2,7 @@
 fd=1
 group_fd=-1
 flags=0
+cpu=*
 type=0
 size=96
 config=0
-- 
1.7.11.7


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

* [PATCH 4/5] perf tests: Add attr record -C cpu test
  2013-02-25  9:52 [PATCH 0/5] perf tools: Fix -C option for record command Jiri Olsa
                   ` (2 preceding siblings ...)
  2013-02-25  9:52 ` [PATCH 3/5] perf tests: Make attr script test event cpu Jiri Olsa
@ 2013-02-25  9:52 ` Jiri Olsa
  2013-03-21 10:57   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2013-02-25  9:52 ` [PATCH 5/5] perf tests: Add attr stat " Jiri Olsa
  4 siblings, 1 reply; 15+ messages in thread
From: Jiri Olsa @ 2013-02-25  9:52 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,
	David Ahern, Oleg Nesterov

Adding test to validate perf_event_attr data for command:
  'record -C 0'

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: David Ahern <dsahern@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
---
 tools/perf/tests/attr/test-record-C0 | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 tools/perf/tests/attr/test-record-C0

diff --git a/tools/perf/tests/attr/test-record-C0 b/tools/perf/tests/attr/test-record-C0
new file mode 100644
index 0000000..d6a7e43
--- /dev/null
+++ b/tools/perf/tests/attr/test-record-C0
@@ -0,0 +1,13 @@
+[config]
+command = record
+args    = -C 0 kill >/dev/null 2>&1
+
+[event:base-record]
+cpu=0
+
+# no enable on exec for CPU attached
+enable_on_exec=0
+
+# PERF_SAMPLE_IP | PERF_SAMPLE_TID PERF_SAMPLE_TIME | # PERF_SAMPLE_PERIOD
+# + PERF_SAMPLE_CPU added by -C 0
+sample_type=391
-- 
1.7.11.7


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

* [PATCH 5/5] perf tests: Add attr stat -C cpu test
  2013-02-25  9:52 [PATCH 0/5] perf tools: Fix -C option for record command Jiri Olsa
                   ` (3 preceding siblings ...)
  2013-02-25  9:52 ` [PATCH 4/5] perf tests: Add attr record -C cpu test Jiri Olsa
@ 2013-02-25  9:52 ` Jiri Olsa
  2013-03-21 10:58   ` [tip:perf/core] " tip-bot for Jiri Olsa
  4 siblings, 1 reply; 15+ messages in thread
From: Jiri Olsa @ 2013-02-25  9:52 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,
	David Ahern, Oleg Nesterov

Adding test to validate perf_event_attr data for command:
  'stat -C 0'

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: David Ahern <dsahern@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
---
 tools/perf/tests/attr/test-stat-C0 | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 tools/perf/tests/attr/test-stat-C0

diff --git a/tools/perf/tests/attr/test-stat-C0 b/tools/perf/tests/attr/test-stat-C0
new file mode 100644
index 0000000..aa83595
--- /dev/null
+++ b/tools/perf/tests/attr/test-stat-C0
@@ -0,0 +1,9 @@
+[config]
+command = stat
+args    = -e cycles -C 0 kill >/dev/null 2>&1
+ret     = 1
+
+[event:base-stat]
+# events are enabled by default when attached to cpu
+disabled=0
+enable_on_exec=0
-- 
1.7.11.7


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

* Re: [PATCH 1/5] perf tools: Fix -C option for record command
  2013-02-25  9:52 ` [PATCH 1/5] " Jiri Olsa
@ 2013-02-25 18:39   ` Oleg Nesterov
  2013-02-25 18:56     ` David Ahern
  2013-03-18 10:53   ` [tip:perf/urgent] perf record: Fix -C option tip-bot for Jiri Olsa
  1 sibling, 1 reply; 15+ messages in thread
From: Oleg Nesterov @ 2013-02-25 18:39 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, David Ahern

To clarify, I am not trying to review this patch, I'd like to ask
the question...

On 02/25, Jiri Olsa wrote:
>
> Currently the -C option does not work for record command,
> because of the targets mismatch when synthesizing threads.
>
> Fixing this by using proper target interface for the
> synthesize decision.

OK, but my fix had the different goal. I thought that

	$ perf ... record -C0 sleep 1

should attach the counter to the child process (workload) and set
event->cpu = 0 (instead of -1). With this patch we create the cpu
counter and event->task == NULL (thanks for your private explanations
btw ;).

But note that (iirc, I didn't even try to read this code again)

	$ perf ... record -a sleep 1

attaches the counter to the task, and I think that -a/C should be
consistent.


However,

> @@ -573,13 +573,15 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
>  					 perf_event__synthesize_guest_os, tool);
>  	}
>
> -	if (!opts->target.system_wide)
> +	if (perf_target__has_task(&opts->target))
>  		err = perf_event__synthesize_thread_map(tool, evsel_list->threads,
>  						  process_synthesized_event,
>  						  machine);
> -	else
> +	else if (perf_target__has_cpu(&opts->target))
>  		err = perf_event__synthesize_threads(tool, process_synthesized_event,

I do agree, this should be changed too, because "-a sleep 1"
sets ->target.system_wide.

Oleg.


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

* Re: [PATCH 1/5] perf tools: Fix -C option for record command
  2013-02-25 18:39   ` Oleg Nesterov
@ 2013-02-25 18:56     ` David Ahern
  2013-02-25 19:38       ` Jiri Olsa
  0 siblings, 1 reply; 15+ messages in thread
From: David Ahern @ 2013-02-25 18:56 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Jiri Olsa, linux-kernel, Arnaldo Carvalho de Melo,
	Peter Zijlstra, Ingo Molnar, Paul Mackerras, Corey Ashford,
	Frederic Weisbecker, Namhyung Kim

On 2/25/13 11:39 AM, Oleg Nesterov wrote:
> To clarify, I am not trying to review this patch, I'd like to ask
> the question...
>
> On 02/25, Jiri Olsa wrote:
>>
>> Currently the -C option does not work for record command,
>> because of the targets mismatch when synthesizing threads.
>>
>> Fixing this by using proper target interface for the
>> synthesize decision.
>
> OK, but my fix had the different goal. I thought that
>
> 	$ perf ... record -C0 sleep 1
>
> should attach the counter to the child process (workload) and set
> event->cpu = 0 (instead of -1). With this patch we create the cpu

If a target is given (-a, -C, -p or -t) that is what the data is 
collected for -- all cpus, a cpu, or one or more task ids. The workload 
in that case becomes a means for bounding the data collection (start and 
end points).

If you want to collect events for a workload you just run perf-record -- 
workload.

Last time I dug into it (which was 8-12 months ago) -C required -a to 
work properly. -a (system_wide) meaning collect events for all cpus and 
then -C meaning but only for this cpu. Perhaps Namyhung's target changes 
may have simplified fixing that as Jiri's patch suggests.

David

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

* Re: [PATCH 1/5] perf tools: Fix -C option for record command
  2013-02-25 18:56     ` David Ahern
@ 2013-02-25 19:38       ` Jiri Olsa
  2013-02-26 14:38         ` Oleg Nesterov
  0 siblings, 1 reply; 15+ messages in thread
From: Jiri Olsa @ 2013-02-25 19:38 UTC (permalink / raw)
  To: David Ahern
  Cc: Oleg Nesterov, linux-kernel, Arnaldo Carvalho de Melo,
	Peter Zijlstra, Ingo Molnar, Paul Mackerras, Corey Ashford,
	Frederic Weisbecker, Namhyung Kim

On Mon, Feb 25, 2013 at 11:56:38AM -0700, David Ahern wrote:
> On 2/25/13 11:39 AM, Oleg Nesterov wrote:
> >To clarify, I am not trying to review this patch, I'd like to ask
> >the question...
> >
> >On 02/25, Jiri Olsa wrote:
> >>
> >>Currently the -C option does not work for record command,
> >>because of the targets mismatch when synthesizing threads.
> >>
> >>Fixing this by using proper target interface for the
> >>synthesize decision.
> >
> >OK, but my fix had the different goal. I thought that
> >
> >	$ perf ... record -C0 sleep 1
> >
> >should attach the counter to the child process (workload) and set
> >event->cpu = 0 (instead of -1). With this patch we create the cpu
> 
> If a target is given (-a, -C, -p or -t) that is what the data is
> collected for -- all cpus, a cpu, or one or more task ids. The
> workload in that case becomes a means for bounding the data
> collection (start and end points).
> 
> If you want to collect events for a workload you just run
> perf-record -- workload.
> 
> Last time I dug into it (which was 8-12 months ago) -C required -a
> to work properly. -a (system_wide) meaning collect events for all
> cpus and then -C meaning but only for this cpu. Perhaps Namyhung's
> target changes may have simplified fixing that as Jiri's patch
> suggests.

yes, that's what actually this patch fixies.. now you can run:

  perf record -C 0 ls

and that will attach to cpu 0 only (same as '-a -C 0' before)


maybe we could consider having:

  perf record -C 0 ls
    - attaching to CPU 0 and ls workload pid

  perf record -a -C 0 ls
    - attaching to CPU 0 globaly

jirka

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

* Re: [PATCH 1/5] perf tools: Fix -C option for record command
  2013-02-25 19:38       ` Jiri Olsa
@ 2013-02-26 14:38         ` Oleg Nesterov
  0 siblings, 0 replies; 15+ messages in thread
From: Oleg Nesterov @ 2013-02-26 14:38 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: David Ahern, linux-kernel, Arnaldo Carvalho de Melo,
	Peter Zijlstra, Ingo Molnar, Paul Mackerras, Corey Ashford,
	Frederic Weisbecker, Namhyung Kim

On 02/25, Jiri Olsa wrote:
>
> On Mon, Feb 25, 2013 at 11:56:38AM -0700, David Ahern wrote:
>
> > If a target is given (-a, -C, -p or -t) that is what the data is
> > collected for -- all cpus, a cpu, or one or more task ids. The
> > workload in that case becomes a means for bounding the data
> > collection (start and end points).

OK, so I misunderstood the intent and misread the code. Thanks
David.

> yes, that's what actually this patch fixies.. now you can run:
>
>   perf record -C 0 ls
>
> and that will attach to cpu 0 only (same as '-a -C 0' before)

Yes, and thus this is consistent with -a and correct. Thanks and
sorry for noise.


But,

> maybe we could consider having:
>
>   perf record -C 0 ls
>     - attaching to CPU 0 and ls workload pid
>
>   perf record -a -C 0 ls
>     - attaching to CPU 0 globaly

Can't really comment since I am not a perf user, but imho looks good.

And useful. And least this behaviour was useful to me when I tried
to test the perf/uprobe changes.

Oleg.


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

* [tip:perf/urgent] perf record: Fix -C option
  2013-02-25  9:52 ` [PATCH 1/5] " Jiri Olsa
  2013-02-25 18:39   ` Oleg Nesterov
@ 2013-03-18 10:53   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 15+ messages in thread
From: tip-bot for Jiri Olsa @ 2013-03-18 10:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, namhyung,
	jolsa, fweisbec, dsahern, tglx, oleg, cjashfor, mingo

Commit-ID:  e4dd45fe7add0de09e0e5b2b511732d9c86b6ee7
Gitweb:     http://git.kernel.org/tip/e4dd45fe7add0de09e0e5b2b511732d9c86b6ee7
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Mon, 25 Feb 2013 10:52:48 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 13 Mar 2013 16:58:28 -0300

perf record: Fix -C option

Currently the -C option does not work for record command, because of the
targets mismatch when synthesizing threads.

Fixing this by using proper target interface for the synthesize
decision.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Reported-by: Oleg Nesterov <oleg@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: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1361785972-7431-2-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-record.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 774c907..f1a939e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -573,13 +573,15 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
 					 perf_event__synthesize_guest_os, tool);
 	}
 
-	if (!opts->target.system_wide)
+	if (perf_target__has_task(&opts->target))
 		err = perf_event__synthesize_thread_map(tool, evsel_list->threads,
 						  process_synthesized_event,
 						  machine);
-	else
+	else if (perf_target__has_cpu(&opts->target))
 		err = perf_event__synthesize_threads(tool, process_synthesized_event,
 					       machine);
+	else /* command specified */
+		err = 0;
 
 	if (err != 0)
 		goto out_delete_session;

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

* [tip:perf/core] perf tests: Make attr script verbose friendly
  2013-02-25  9:52 ` [PATCH 2/5] perf tests: Make attr script verbose friendly Jiri Olsa
@ 2013-03-21 10:54   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Jiri Olsa @ 2013-03-21 10:54 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, namhyung,
	jolsa, fweisbec, dsahern, oleg, tglx, cjashfor, mingo

Commit-ID:  097c87582c5719adbd8b700f4250e1f1d9f15ebf
Gitweb:     http://git.kernel.org/tip/097c87582c5719adbd8b700f4250e1f1d9f15ebf
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Mon, 25 Feb 2013 10:52:49 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Mar 2013 13:05:59 -0300

perf tests: Make attr script verbose friendly

Making the attr test script runner to pass proper verbose option. Also
making single '-v' be more reader friendly and display just the test
name.

Making the current output to be display for '-vv'.

Signed-off-by: Jiri Olsa <jolsa@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: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1361785972-7431-3-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/attr.c  | 9 +++++++--
 tools/perf/tests/attr.py | 4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index bdcceb8..038de3e 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -147,10 +147,15 @@ void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
 
 static int run_dir(const char *d, const char *perf)
 {
+	char v[] = "-vvvvv";
+	int vcnt = min(verbose, (int) sizeof(v) - 1);
 	char cmd[3*PATH_MAX];
 
-	snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %s",
-		 d, d, perf, verbose ? "-v" : "");
+	if (verbose)
+		vcnt++;
+
+	snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
+		 d, d, perf, vcnt, v);
 
 	return system(cmd);
 }
diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py
index 2f629ca..e0ea513 100644
--- a/tools/perf/tests/attr.py
+++ b/tools/perf/tests/attr.py
@@ -121,7 +121,7 @@ class Test(object):
         parser = ConfigParser.SafeConfigParser()
         parser.read(path)
 
-        log.debug("running '%s'" % path)
+        log.warning("running '%s'" % path)
 
         self.path     = path
         self.test_dir = options.test_dir
@@ -172,7 +172,7 @@ class Test(object):
               self.perf, self.command, tempdir, self.args)
         ret = os.WEXITSTATUS(os.system(cmd))
 
-        log.warning("  running '%s' ret %d " % (cmd, ret))
+        log.info("  '%s' ret %d " % (cmd, ret))
 
         if ret != int(self.ret):
             raise Unsup(self)

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

* [tip:perf/core] perf tests: Make attr script test event cpu
  2013-02-25  9:52 ` [PATCH 3/5] perf tests: Make attr script test event cpu Jiri Olsa
@ 2013-03-21 10:55   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Jiri Olsa @ 2013-03-21 10:55 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, namhyung,
	jolsa, fweisbec, dsahern, oleg, tglx, cjashfor, mingo

Commit-ID:  c21d0030cfe17d87f8ad80a4205c8203bdb3949b
Gitweb:     http://git.kernel.org/tip/c21d0030cfe17d87f8ad80a4205c8203bdb3949b
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Mon, 25 Feb 2013 10:52:50 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Mar 2013 13:06:00 -0300

perf tests: Make attr script test event cpu

Make attr script to check for 'cpu' when testing event properties. This
will allow us to check the '-C X' option for both record and stat
commands.

Signed-off-by: Jiri Olsa <jolsa@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: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1361785972-7431-4-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/attr.py          | 1 +
 tools/perf/tests/attr/base-record | 1 +
 tools/perf/tests/attr/base-stat   | 1 +
 3 files changed, 3 insertions(+)

diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py
index e0ea513..c9b4b62 100644
--- a/tools/perf/tests/attr.py
+++ b/tools/perf/tests/attr.py
@@ -24,6 +24,7 @@ class Unsup(Exception):
 
 class Event(dict):
     terms = [
+        'cpu',
         'flags',
         'type',
         'size',
diff --git a/tools/perf/tests/attr/base-record b/tools/perf/tests/attr/base-record
index 5bc3880..b4fc835 100644
--- a/tools/perf/tests/attr/base-record
+++ b/tools/perf/tests/attr/base-record
@@ -2,6 +2,7 @@
 fd=1
 group_fd=-1
 flags=0
+cpu=*
 type=0|1
 size=96
 config=0
diff --git a/tools/perf/tests/attr/base-stat b/tools/perf/tests/attr/base-stat
index 4bd79a8..748ee94 100644
--- a/tools/perf/tests/attr/base-stat
+++ b/tools/perf/tests/attr/base-stat
@@ -2,6 +2,7 @@
 fd=1
 group_fd=-1
 flags=0
+cpu=*
 type=0
 size=96
 config=0

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

* [tip:perf/core] perf tests: Add attr record -C cpu test
  2013-02-25  9:52 ` [PATCH 4/5] perf tests: Add attr record -C cpu test Jiri Olsa
@ 2013-03-21 10:57   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Jiri Olsa @ 2013-03-21 10:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, namhyung,
	jolsa, fweisbec, dsahern, oleg, tglx, cjashfor, mingo

Commit-ID:  b03ec1b53070e0fae9de72b584d94b65a4a97635
Gitweb:     http://git.kernel.org/tip/b03ec1b53070e0fae9de72b584d94b65a4a97635
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Mon, 25 Feb 2013 10:52:51 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Mar 2013 13:06:00 -0300

perf tests: Add attr record -C cpu test

Adding test to validate perf_event_attr data for command:
  'record -C 0'

Signed-off-by: Jiri Olsa <jolsa@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: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1361785972-7431-5-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/attr/test-record-C0 | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tools/perf/tests/attr/test-record-C0 b/tools/perf/tests/attr/test-record-C0
new file mode 100644
index 0000000..d6a7e43
--- /dev/null
+++ b/tools/perf/tests/attr/test-record-C0
@@ -0,0 +1,13 @@
+[config]
+command = record
+args    = -C 0 kill >/dev/null 2>&1
+
+[event:base-record]
+cpu=0
+
+# no enable on exec for CPU attached
+enable_on_exec=0
+
+# PERF_SAMPLE_IP | PERF_SAMPLE_TID PERF_SAMPLE_TIME | # PERF_SAMPLE_PERIOD
+# + PERF_SAMPLE_CPU added by -C 0
+sample_type=391

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

* [tip:perf/core] perf tests: Add attr stat -C cpu test
  2013-02-25  9:52 ` [PATCH 5/5] perf tests: Add attr stat " Jiri Olsa
@ 2013-03-21 10:58   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Jiri Olsa @ 2013-03-21 10:58 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, namhyung,
	jolsa, fweisbec, dsahern, oleg, tglx, cjashfor, mingo

Commit-ID:  9687b89d21999301ed386855c04b60d00ed1ec02
Gitweb:     http://git.kernel.org/tip/9687b89d21999301ed386855c04b60d00ed1ec02
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Mon, 25 Feb 2013 10:52:52 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Mar 2013 13:06:00 -0300

perf tests: Add attr stat -C cpu test

Adding test to validate perf_event_attr data for command:
  'stat -C 0'

Signed-off-by: Jiri Olsa <jolsa@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: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1361785972-7431-6-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/attr/test-stat-C0 | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/tests/attr/test-stat-C0 b/tools/perf/tests/attr/test-stat-C0
new file mode 100644
index 0000000..aa83595
--- /dev/null
+++ b/tools/perf/tests/attr/test-stat-C0
@@ -0,0 +1,9 @@
+[config]
+command = stat
+args    = -e cycles -C 0 kill >/dev/null 2>&1
+ret     = 1
+
+[event:base-stat]
+# events are enabled by default when attached to cpu
+disabled=0
+enable_on_exec=0

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

end of thread, other threads:[~2013-03-21 11:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-25  9:52 [PATCH 0/5] perf tools: Fix -C option for record command Jiri Olsa
2013-02-25  9:52 ` [PATCH 1/5] " Jiri Olsa
2013-02-25 18:39   ` Oleg Nesterov
2013-02-25 18:56     ` David Ahern
2013-02-25 19:38       ` Jiri Olsa
2013-02-26 14:38         ` Oleg Nesterov
2013-03-18 10:53   ` [tip:perf/urgent] perf record: Fix -C option tip-bot for Jiri Olsa
2013-02-25  9:52 ` [PATCH 2/5] perf tests: Make attr script verbose friendly Jiri Olsa
2013-03-21 10:54   ` [tip:perf/core] " tip-bot for Jiri Olsa
2013-02-25  9:52 ` [PATCH 3/5] perf tests: Make attr script test event cpu Jiri Olsa
2013-03-21 10:55   ` [tip:perf/core] " tip-bot for Jiri Olsa
2013-02-25  9:52 ` [PATCH 4/5] perf tests: Add attr record -C cpu test Jiri Olsa
2013-03-21 10:57   ` [tip:perf/core] " tip-bot for Jiri Olsa
2013-02-25  9:52 ` [PATCH 5/5] perf tests: Add attr stat " Jiri Olsa
2013-03-21 10:58   ` [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.