diff options
author | Stephane Eranian <eranian@google.com> | 2010-05-12 04:40:01 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-13 15:39:12 -0400 |
commit | 2e6cdf996ba43ce0b090ffbf754f83e17362cd69 (patch) | |
tree | bb471a4ae13fa3941612c30c75bead7417084667 /tools | |
parent | 8a0ecfb8b47dc765fdf460913231876bbc95385e (diff) |
perf tools: change event inheritance logic in stat and record
By default, event inheritance across fork and pthread_create was on but the -i
option of stat and record, which enabled inheritance, led to believe it was off
by default.
This patch fixes this logic by inverting the meaning of the -i option. By
default inheritance is on whether you attach to a process (-p), a thread (-t)
or start a process. If you pass -i, then you turn off inheritance. Turning off
inheritance if you don't need it, helps limit perf resource usage as well.
The patch also fixes perf stat -t xxxx and perf record -t xxxx which did not
start the counters.
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <4bea9d2f.d60ce30a.0b5b.08e1@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Documentation/perf-record.txt | 4 | ||||
-rw-r--r-- | tools/perf/Documentation/perf-stat.txt | 4 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 12 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 10 |
4 files changed, 15 insertions, 15 deletions
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 020d871c7934..34e255fc3e2f 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt | |||
@@ -69,8 +69,8 @@ OPTIONS | |||
69 | Output file name. | 69 | Output file name. |
70 | 70 | ||
71 | -i:: | 71 | -i:: |
72 | --inherit:: | 72 | --no-inherit:: |
73 | Child tasks inherit counters. | 73 | Child tasks do not inherit counters. |
74 | -F:: | 74 | -F:: |
75 | --freq=:: | 75 | --freq=:: |
76 | Profile at this frequency. | 76 | Profile at this frequency. |
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index 484080dd5b6f..2cab8e8c33d0 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt | |||
@@ -31,8 +31,8 @@ OPTIONS | |||
31 | hexadecimal event descriptor. | 31 | hexadecimal event descriptor. |
32 | 32 | ||
33 | -i:: | 33 | -i:: |
34 | --inherit:: | 34 | --no-inherit:: |
35 | child tasks inherit counters | 35 | child tasks do not inherit counters |
36 | -p:: | 36 | -p:: |
37 | --pid=<pid>:: | 37 | --pid=<pid>:: |
38 | stat events on existing pid | 38 | stat events on existing pid |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 6b77b285fe10..0f467cf7aa72 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -54,7 +54,7 @@ static pid_t target_tid = -1; | |||
54 | static pid_t *all_tids = NULL; | 54 | static pid_t *all_tids = NULL; |
55 | static int thread_num = 0; | 55 | static int thread_num = 0; |
56 | static pid_t child_pid = -1; | 56 | static pid_t child_pid = -1; |
57 | static bool inherit = true; | 57 | static bool no_inherit = false; |
58 | static enum write_mode_t write_mode = WRITE_FORCE; | 58 | static enum write_mode_t write_mode = WRITE_FORCE; |
59 | static bool call_graph = false; | 59 | static bool call_graph = false; |
60 | static bool inherit_stat = false; | 60 | static bool inherit_stat = false; |
@@ -298,8 +298,8 @@ static void create_counter(int counter, int cpu) | |||
298 | 298 | ||
299 | attr->mmap = track; | 299 | attr->mmap = track; |
300 | attr->comm = track; | 300 | attr->comm = track; |
301 | attr->inherit = inherit; | 301 | attr->inherit = !no_inherit; |
302 | if (target_pid == -1 && !system_wide) { | 302 | if (target_pid == -1 && target_tid == -1 && !system_wide) { |
303 | attr->disabled = 1; | 303 | attr->disabled = 1; |
304 | attr->enable_on_exec = 1; | 304 | attr->enable_on_exec = 1; |
305 | } | 305 | } |
@@ -641,7 +641,7 @@ static int __cmd_record(int argc, const char **argv) | |||
641 | close(child_ready_pipe[0]); | 641 | close(child_ready_pipe[0]); |
642 | } | 642 | } |
643 | 643 | ||
644 | if ((!system_wide && !inherit) || profile_cpu != -1) { | 644 | if ((!system_wide && no_inherit) || profile_cpu != -1) { |
645 | open_counters(profile_cpu); | 645 | open_counters(profile_cpu); |
646 | } else { | 646 | } else { |
647 | nr_cpus = read_cpu_map(); | 647 | nr_cpus = read_cpu_map(); |
@@ -821,8 +821,8 @@ static const struct option options[] = { | |||
821 | "event period to sample"), | 821 | "event period to sample"), |
822 | OPT_STRING('o', "output", &output_name, "file", | 822 | OPT_STRING('o', "output", &output_name, "file", |
823 | "output file name"), | 823 | "output file name"), |
824 | OPT_BOOLEAN('i', "inherit", &inherit, | 824 | OPT_BOOLEAN('i', "no-inherit", &no_inherit, |
825 | "child tasks inherit counters"), | 825 | "child tasks do not inherit counters"), |
826 | OPT_INTEGER('F', "freq", &user_freq, | 826 | OPT_INTEGER('F', "freq", &user_freq, |
827 | "profile at this frequency"), | 827 | "profile at this frequency"), |
828 | OPT_INTEGER('m', "mmap-pages", &mmap_pages, | 828 | OPT_INTEGER('m', "mmap-pages", &mmap_pages, |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index e619ac89dff5..ff8c413b7e73 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -72,7 +72,7 @@ static unsigned int nr_cpus = 0; | |||
72 | static int run_idx = 0; | 72 | static int run_idx = 0; |
73 | 73 | ||
74 | static int run_count = 1; | 74 | static int run_count = 1; |
75 | static bool inherit = true; | 75 | static bool no_inherit = false; |
76 | static bool scale = true; | 76 | static bool scale = true; |
77 | static pid_t target_pid = -1; | 77 | static pid_t target_pid = -1; |
78 | static pid_t target_tid = -1; | 78 | static pid_t target_tid = -1; |
@@ -167,8 +167,8 @@ static int create_perf_stat_counter(int counter) | |||
167 | ++ncreated; | 167 | ++ncreated; |
168 | } | 168 | } |
169 | } else { | 169 | } else { |
170 | attr->inherit = inherit; | 170 | attr->inherit = !no_inherit; |
171 | if (target_pid == -1) { | 171 | if (target_pid == -1 && target_tid == -1) { |
172 | attr->disabled = 1; | 172 | attr->disabled = 1; |
173 | attr->enable_on_exec = 1; | 173 | attr->enable_on_exec = 1; |
174 | } | 174 | } |
@@ -518,8 +518,8 @@ static const struct option options[] = { | |||
518 | OPT_CALLBACK('e', "event", NULL, "event", | 518 | OPT_CALLBACK('e', "event", NULL, "event", |
519 | "event selector. use 'perf list' to list available events", | 519 | "event selector. use 'perf list' to list available events", |
520 | parse_events), | 520 | parse_events), |
521 | OPT_BOOLEAN('i', "inherit", &inherit, | 521 | OPT_BOOLEAN('i', "no-inherit", &no_inherit, |
522 | "child tasks inherit counters"), | 522 | "child tasks do not inherit counters"), |
523 | OPT_INTEGER('p', "pid", &target_pid, | 523 | OPT_INTEGER('p', "pid", &target_pid, |
524 | "stat events on existing process id"), | 524 | "stat events on existing process id"), |
525 | OPT_INTEGER('t', "tid", &target_tid, | 525 | OPT_INTEGER('t', "tid", &target_tid, |