perf stat: fix scale option
PATCH 1/1 perf stat: fix scale option
The scale option defaults to true and the command line option only allows it to be set to true. ie. the option is a no-op.
Changes the scale option to no_scale to maintain current default of scaling enabled; no_scale set to true then disables scaling.
--- tools/perf/builtin-stat.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
tools/perf/builtin-stat.c +6 -6
@@ -77,7 +77,7 @@ static int run_idx = 0;static int run_count =1 ;static bool no_inherit = false; -static bool scale = true; +static bool no_scale = false;static bool no_aggr = false;static pid_t target_pid =-1 ;static pid_t target_tid =-1 ;
@@ -161,7 +161,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel) {struct perf_event_attr *attr = &evsel->attr; -if (scale) +if (!no_scale) attr->read_format =PERF_FORMAT_TOTAL_TIME_ENABLED |PERF_FORMAT_TOTAL_TIME_RUNNING ;
@@ -199,7 +199,7 @@ static int read_counter_aggr(struct perf_evsel *counter)u64 *count = counter->counts->aggr.values;int i; -if (__perf_evsel__read (counter, cpus->nr, threads->nr, scale) <0 ) +if (__perf_evsel__read (counter, cpus->nr, threads->nr, !no_scale) <0 )return -1 ;for (i =0 ; i <3 ; i++)
@@ -233,7 +233,7 @@ static int read_counter(struct perf_evsel *counter)int cpu;for (cpu =0 ; cpu < cpus->nr; cpu++) { -if (__perf_evsel__read_on_cpu (counter, cpu,0 , scale) <0 ) +if (__perf_evsel__read_on_cpu (counter, cpu,0 , !no_scale) <0 )return -1 ; count = counter->counts->cpu[cpu].values;
@@ -619,8 +619,8 @@ static const struct option options[] = { "stat events on existing thread id"),OPT_BOOLEAN ('a' ,"all-cpus" , &system_wide,"system-wide collection from all CPUs" ), -OPT_BOOLEAN ('c' ,"scale" , &scale, -"scale/normalize counters" ), +OPT_BOOLEAN ('c' ,"no-scale" , &no_scale, +"disable scaling / normalization of counters" ),OPT_INCR ('v' ,"verbose" , &verbose,"be more verbose (show counter open errors, etc)" ), OPT_INTEGER('r', "repeat", &run_count,
Signature · 1 line
1.7.3.4
Quoted 2 lines · David Ahern
The scale option defaults to true and the command line option only allows it to be set to true. ie. the option is a no-op.
Hm, the option parser should already allow --no-scale. Does that not work for you?
Thanks,
Ingo
Quoted 11 lines · Ingo Molnar
Quoted 2 lines · David Ahern
The scale option defaults to true and the command line option only allows it to be set to true. ie. the option is a no-op.
Hm, the option parser should already allow --no-scale. Does that not work for you?
Thanks,
Ingo
Indeed it does work; I was not aware of that option. What about the '-c' option being a no-op?
David
Quoted 7 lines · David Ahern
Quoted 6 lines · Ingo Molnar
Quoted 2 lines · David Ahern
The scale option defaults to true and the command line option only allows it to be set to true. ie. the option is a no-op.
Quoted 8 lines
Quoted 5 lines
Hm, the option parser should already allow --no-scale. Does that not work for you?
Thanks,
Ingo
Indeed it does work; I was not aware of that option. What about the '-c' option being a no-op?
Yeah, that's indeed inconsistent and we could flip the option around i suspect.
Thanks,
Ingo