mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-08 14:13:53 +00:00
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>
This commit is contained in:
parent
8a0ecfb8b4
commit
2e6cdf996b
@ -69,8 +69,8 @@ OPTIONS
|
|||||||
Output file name.
|
Output file name.
|
||||||
|
|
||||||
-i::
|
-i::
|
||||||
--inherit::
|
--no-inherit::
|
||||||
Child tasks inherit counters.
|
Child tasks do not inherit counters.
|
||||||
-F::
|
-F::
|
||||||
--freq=::
|
--freq=::
|
||||||
Profile at this frequency.
|
Profile at this frequency.
|
||||||
|
@ -31,8 +31,8 @@ OPTIONS
|
|||||||
hexadecimal event descriptor.
|
hexadecimal event descriptor.
|
||||||
|
|
||||||
-i::
|
-i::
|
||||||
--inherit::
|
--no-inherit::
|
||||||
child tasks inherit counters
|
child tasks do not inherit counters
|
||||||
-p::
|
-p::
|
||||||
--pid=<pid>::
|
--pid=<pid>::
|
||||||
stat events on existing pid
|
stat events on existing pid
|
||||||
|
@ -54,7 +54,7 @@ static pid_t target_tid = -1;
|
|||||||
static pid_t *all_tids = NULL;
|
static pid_t *all_tids = NULL;
|
||||||
static int thread_num = 0;
|
static int thread_num = 0;
|
||||||
static pid_t child_pid = -1;
|
static pid_t child_pid = -1;
|
||||||
static bool inherit = true;
|
static bool no_inherit = false;
|
||||||
static enum write_mode_t write_mode = WRITE_FORCE;
|
static enum write_mode_t write_mode = WRITE_FORCE;
|
||||||
static bool call_graph = false;
|
static bool call_graph = false;
|
||||||
static bool inherit_stat = false;
|
static bool inherit_stat = false;
|
||||||
@ -298,8 +298,8 @@ static void create_counter(int counter, int cpu)
|
|||||||
|
|
||||||
attr->mmap = track;
|
attr->mmap = track;
|
||||||
attr->comm = track;
|
attr->comm = track;
|
||||||
attr->inherit = inherit;
|
attr->inherit = !no_inherit;
|
||||||
if (target_pid == -1 && !system_wide) {
|
if (target_pid == -1 && target_tid == -1 && !system_wide) {
|
||||||
attr->disabled = 1;
|
attr->disabled = 1;
|
||||||
attr->enable_on_exec = 1;
|
attr->enable_on_exec = 1;
|
||||||
}
|
}
|
||||||
@ -641,7 +641,7 @@ static int __cmd_record(int argc, const char **argv)
|
|||||||
close(child_ready_pipe[0]);
|
close(child_ready_pipe[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!system_wide && !inherit) || profile_cpu != -1) {
|
if ((!system_wide && no_inherit) || profile_cpu != -1) {
|
||||||
open_counters(profile_cpu);
|
open_counters(profile_cpu);
|
||||||
} else {
|
} else {
|
||||||
nr_cpus = read_cpu_map();
|
nr_cpus = read_cpu_map();
|
||||||
@ -821,8 +821,8 @@ static const struct option options[] = {
|
|||||||
"event period to sample"),
|
"event period to sample"),
|
||||||
OPT_STRING('o', "output", &output_name, "file",
|
OPT_STRING('o', "output", &output_name, "file",
|
||||||
"output file name"),
|
"output file name"),
|
||||||
OPT_BOOLEAN('i', "inherit", &inherit,
|
OPT_BOOLEAN('i', "no-inherit", &no_inherit,
|
||||||
"child tasks inherit counters"),
|
"child tasks do not inherit counters"),
|
||||||
OPT_INTEGER('F', "freq", &user_freq,
|
OPT_INTEGER('F', "freq", &user_freq,
|
||||||
"profile at this frequency"),
|
"profile at this frequency"),
|
||||||
OPT_INTEGER('m', "mmap-pages", &mmap_pages,
|
OPT_INTEGER('m', "mmap-pages", &mmap_pages,
|
||||||
|
@ -72,7 +72,7 @@ static unsigned int nr_cpus = 0;
|
|||||||
static int run_idx = 0;
|
static int run_idx = 0;
|
||||||
|
|
||||||
static int run_count = 1;
|
static int run_count = 1;
|
||||||
static bool inherit = true;
|
static bool no_inherit = false;
|
||||||
static bool scale = true;
|
static bool scale = true;
|
||||||
static pid_t target_pid = -1;
|
static pid_t target_pid = -1;
|
||||||
static pid_t target_tid = -1;
|
static pid_t target_tid = -1;
|
||||||
@ -167,8 +167,8 @@ static int create_perf_stat_counter(int counter)
|
|||||||
++ncreated;
|
++ncreated;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
attr->inherit = inherit;
|
attr->inherit = !no_inherit;
|
||||||
if (target_pid == -1) {
|
if (target_pid == -1 && target_tid == -1) {
|
||||||
attr->disabled = 1;
|
attr->disabled = 1;
|
||||||
attr->enable_on_exec = 1;
|
attr->enable_on_exec = 1;
|
||||||
}
|
}
|
||||||
@ -518,8 +518,8 @@ static const struct option options[] = {
|
|||||||
OPT_CALLBACK('e', "event", NULL, "event",
|
OPT_CALLBACK('e', "event", NULL, "event",
|
||||||
"event selector. use 'perf list' to list available events",
|
"event selector. use 'perf list' to list available events",
|
||||||
parse_events),
|
parse_events),
|
||||||
OPT_BOOLEAN('i', "inherit", &inherit,
|
OPT_BOOLEAN('i', "no-inherit", &no_inherit,
|
||||||
"child tasks inherit counters"),
|
"child tasks do not inherit counters"),
|
||||||
OPT_INTEGER('p', "pid", &target_pid,
|
OPT_INTEGER('p', "pid", &target_pid,
|
||||||
"stat events on existing process id"),
|
"stat events on existing process id"),
|
||||||
OPT_INTEGER('t', "tid", &target_tid,
|
OPT_INTEGER('t', "tid", &target_tid,
|
||||||
|
Loading…
Reference in New Issue
Block a user