Skip to content

Commit 711a572

Browse files
olsajiriacmel
authored andcommitted
perf stat: Move 'scale' into struct perf_stat_config
Moving 'scale' into struct perf_stat_config. The point is to centralize the base stat config so it could be used localy together with other stat routines in other parts of perf code. Signed-off-by: Jiri Olsa <[email protected]> Cc: David Ahern <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 421a50f commit 711a572

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

tools/perf/builtin-stat.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ static struct target target = {
101101

102102
static int run_count = 1;
103103
static bool no_inherit = false;
104-
static bool scale = true;
105104
static volatile pid_t child_pid = -1;
106105
static bool null_run = false;
107106
static int detailed_run = 0;
@@ -127,6 +126,7 @@ static volatile int done = 0;
127126

128127
static struct perf_stat_config stat_config = {
129128
.aggr_mode = AGGR_GLOBAL,
129+
.scale = true,
130130
};
131131

132132
static inline void diff_timespec(struct timespec *r, struct timespec *a,
@@ -151,7 +151,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
151151
{
152152
struct perf_event_attr *attr = &evsel->attr;
153153

154-
if (scale)
154+
if (stat_config.scale)
155155
attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
156156
PERF_FORMAT_TOTAL_TIME_RUNNING;
157157

@@ -240,13 +240,13 @@ process_counter_values(struct perf_evsel *evsel, int cpu, int thread,
240240
case AGGR_NONE:
241241
if (!evsel->snapshot)
242242
perf_evsel__compute_deltas(evsel, cpu, thread, count);
243-
perf_counts_values__scale(count, scale, NULL);
243+
perf_counts_values__scale(count, stat_config.scale, NULL);
244244
if (stat_config.aggr_mode == AGGR_NONE)
245245
perf_stat__update_shadow_stats(evsel, count->values, cpu);
246246
break;
247247
case AGGR_GLOBAL:
248248
aggr->val += count->val;
249-
if (scale) {
249+
if (stat_config.scale) {
250250
aggr->ena += count->ena;
251251
aggr->run += count->run;
252252
}
@@ -299,7 +299,7 @@ static int process_counter(struct perf_evsel *counter)
299299

300300
if (!counter->snapshot)
301301
perf_evsel__compute_deltas(counter, -1, -1, aggr);
302-
perf_counts_values__scale(aggr, scale, &counter->counts->scaled);
302+
perf_counts_values__scale(aggr, stat_config.scale, &counter->counts->scaled);
303303

304304
for (i = 0; i < 3; i++)
305305
update_stats(&ps->res_stats[i], count[i]);
@@ -1274,7 +1274,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
12741274
"system-wide collection from all CPUs"),
12751275
OPT_BOOLEAN('g', "group", &group,
12761276
"put the counters into a counter group"),
1277-
OPT_BOOLEAN('c', "scale", &scale, "scale/normalize counters"),
1277+
OPT_BOOLEAN('c', "scale", &stat_config.scale, "scale/normalize counters"),
12781278
OPT_INCR('v', "verbose", &verbose,
12791279
"be more verbose (show counter open errors, etc)"),
12801280
OPT_INTEGER('r', "repeat", &run_count,

tools/perf/util/stat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct perf_counts {
5252

5353
struct perf_stat_config {
5454
enum aggr_mode aggr_mode;
55+
bool scale;
5556
};
5657

5758
static inline struct perf_counts_values*

0 commit comments

Comments
 (0)