Skip to content

Commit 75998bb

Browse files
Andi Kleenacmel
authored andcommitted
perf stat: Fix --no-scale
The -c option to enable multiplex scaling has been useless for quite some time because scaling is default. It's only useful as --no-scale to disable scaling. But the non scaling code path has bitrotted and doesn't print anything because perf output code relies on value run/ena information. Also even when we don't want to scale a value it's still useful to show its multiplex percentage. This patch: - Fixes help and documentation to show --no-scale instead of -c - Removes -c, only keeps the long option because -c doesn't support negatives. - Enables running/enabled even with --no-scale - And fixes some other problems in the no-scale output. Before: $ perf stat --no-scale -e cycles true Performance counter stats for 'true': <not counted> cycles 0.000984154 seconds time elapsed After: $ ./perf stat --no-scale -e cycles true Performance counter stats for 'true': 706,070 cycles 0.001219821 seconds time elapsed Signed-off-by: Andi Kleen <[email protected]> Acked-by: Jiri Olsa <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> LPU-Reference: [email protected] Link: https://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 90b10f4 commit 75998bb

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

tools/perf/Documentation/perf-stat.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ report::
7272
--all-cpus::
7373
system-wide collection from all CPUs (default if no target is specified)
7474

75-
-c::
76-
--scale::
77-
scale/normalize counter values
75+
--no-scale::
76+
Don't scale/normalize counter values
7877

7978
-d::
8079
--detailed::

tools/perf/builtin-stat.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,8 @@ static struct option stat_options[] = {
718718
"system-wide collection from all CPUs"),
719719
OPT_BOOLEAN('g', "group", &group,
720720
"put the counters into a counter group"),
721-
OPT_BOOLEAN('c', "scale", &stat_config.scale, "scale/normalize counters"),
721+
OPT_BOOLEAN(0, "scale", &stat_config.scale,
722+
"Use --no-scale to disable counter scaling for multiplexing"),
722723
OPT_INCR('v', "verbose", &verbose,
723724
"be more verbose (show counter open errors, etc)"),
724725
OPT_INTEGER('r', "repeat", &stat_config.run_count,

tools/perf/util/evsel.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,8 +1344,7 @@ void perf_counts_values__scale(struct perf_counts_values *count,
13441344
scaled = 1;
13451345
count->val = (u64)((double) count->val * count->ena / count->run + 0.5);
13461346
}
1347-
} else
1348-
count->ena = count->run = 0;
1347+
}
13491348

13501349
if (pscaled)
13511350
*pscaled = scaled;

tools/perf/util/stat.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,8 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel
291291
break;
292292
case AGGR_GLOBAL:
293293
aggr->val += count->val;
294-
if (config->scale) {
295-
aggr->ena += count->ena;
296-
aggr->run += count->run;
297-
}
294+
aggr->ena += count->ena;
295+
aggr->run += count->run;
298296
case AGGR_UNSET:
299297
default:
300298
break;
@@ -442,10 +440,8 @@ int create_perf_stat_counter(struct perf_evsel *evsel,
442440
struct perf_event_attr *attr = &evsel->attr;
443441
struct perf_evsel *leader = evsel->leader;
444442

445-
if (config->scale) {
446-
attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
447-
PERF_FORMAT_TOTAL_TIME_RUNNING;
448-
}
443+
attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
444+
PERF_FORMAT_TOTAL_TIME_RUNNING;
449445

450446
/*
451447
* The event is part of non trivial group, let's enable

0 commit comments

Comments
 (0)