perf: fix stat attach bogus counts
PATCH 1/1 perf: fix stat attach bogus counts
When perf stat -p pid is used, the events must be enabled immediately as there is no exec and thus no enable_on_exec.
--
builtin-stat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/builtin-stat.c +4 -2
@@ -159,8 +159,10 @@ static void create_perf_stat_counter(int counter, int pid) } }else { attr->inherit = inherit; - attr->disabled =1 ; - attr->enable_on_exec =1 ; +if (target_pid ==-1 ) { + attr->disabled =1 ; + attr->enable_on_exec =1 ; + } fd[0 ][counter] =sys_perf_event_open (attr, pid,-1 ,-1 ,0 );if (fd[0 ][counter] <0 && verbose)
Quoted 14 lines · Stephane Eranian
When perf stat -p pid is used, the events must be enabled immediately as there is no exec and thus no
enable_on_exec.Signed-off-by Stephane Eranian <[email protected]>--
builtin-stat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/perf/builtin-stat.c +0
-0
tools/perf/builtin-stat.c static void create_perf_stat_counter(int counter, int pid) · line 165
Quoted 9 lines
tools/perf/builtin-stat.c +4
-2@@ -159,8 +159,10 @@ static void create_perf_stat_counter(int counter, int pid) } }else { attr->inherit = inherit; - attr->disabled =1 ; - attr->enable_on_exec =1 ; +if (target_pid ==-1 ) { + attr->disabled =1 ; + attr->enable_on_exec =1 ; + }
Mind checking latest -tip, which has these commits:
d6d901c: perf events: Change perf parameter --pid to process-wide collection instead of thread-wid 46be604: perf record: Enable counters only when kernel is execing subcommand 6be2850: perf stat: Enable counters when collecting process-wide or system-wide data
as they fix/improve various --pid related behavioral aspects of perf. Does it work fine for you now?
Ingo
Quoted 29 lines · Ingo Molnar
Quoted 14 lines · Stephane Eranian
When perf stat -p pid is used, the events must be enabled immediately as there is no exec and thus no
enable_on_exec.Signed-off-by Stephane Eranian <[email protected]>--
builtin-stat.c | 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)tools/perf/builtin-stat.c +0
-0tools/perf/builtin-stat.c static void create_perf_stat_counter(int counter, int pid) · line 165
Quoted 9 lines
tools/perf/builtin-stat.c +4
-2@@ -159,8 +159,10 @@ static void create_perf_stat_counter(int counter, int pid) } } else { attr->inherit = inherit; - attr->disabled = 1; - attr->enable_on_exec = 1; + if (target_pid == -1) { + attr->disabled = 1; + attr->enable_on_exec = 1; + }Mind checking latest -tip, which has these commits:
Quoted 7 lines
d6d901c: perf events: Change perf parameter --pid to process-wide collection instead of thread-wid 46be604: perf record: Enable counters only when kernel is execing subcommand 6be2850: perf stat: Enable counters when collecting process-wide or system-wide data
as they fix/improve various --pid related behavioral aspects of perf. Does it work fine for you now?
They indeed included the same fix.
So that's fine now.