aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-07-21 08:31:23 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-06 15:02:39 -0400
commit711a572ea8ae7e9ab6575403c6d632d058d5cb3d (patch)
treec05c20bdcc5313d46048cb7338e1f3f412236518 /tools/perf
parent421a50f3fafaf271bb3293378eaafca71337dfec (diff)
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 <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1437481927-29538-4-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-stat.c12
-rw-r--r--tools/perf/util/stat.h1
2 files changed, 7 insertions, 6 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index bafb830b1bd9..3fb2865e519a 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -101,7 +101,6 @@ static struct target target = {
101 101
102static int run_count = 1; 102static int run_count = 1;
103static bool no_inherit = false; 103static bool no_inherit = false;
104static bool scale = true;
105static volatile pid_t child_pid = -1; 104static volatile pid_t child_pid = -1;
106static bool null_run = false; 105static bool null_run = false;
107static int detailed_run = 0; 106static int detailed_run = 0;
@@ -127,6 +126,7 @@ static volatile int done = 0;
127 126
128static struct perf_stat_config stat_config = { 127static struct perf_stat_config stat_config = {
129 .aggr_mode = AGGR_GLOBAL, 128 .aggr_mode = AGGR_GLOBAL,
129 .scale = true,
130}; 130};
131 131
132static inline void diff_timespec(struct timespec *r, struct timespec *a, 132static inline void diff_timespec(struct timespec *r, struct timespec *a,
@@ -151,7 +151,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
151{ 151{
152 struct perf_event_attr *attr = &evsel->attr; 152 struct perf_event_attr *attr = &evsel->attr;
153 153
154 if (scale) 154 if (stat_config.scale)
155 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | 155 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
156 PERF_FORMAT_TOTAL_TIME_RUNNING; 156 PERF_FORMAT_TOTAL_TIME_RUNNING;
157 157
@@ -240,13 +240,13 @@ process_counter_values(struct perf_evsel *evsel, int cpu, int thread,
240 case AGGR_NONE: 240 case AGGR_NONE:
241 if (!evsel->snapshot) 241 if (!evsel->snapshot)
242 perf_evsel__compute_deltas(evsel, cpu, thread, count); 242 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);
244 if (stat_config.aggr_mode == AGGR_NONE) 244 if (stat_config.aggr_mode == AGGR_NONE)
245 perf_stat__update_shadow_stats(evsel, count->values, cpu); 245 perf_stat__update_shadow_stats(evsel, count->values, cpu);
246 break; 246 break;
247 case AGGR_GLOBAL: 247 case AGGR_GLOBAL:
248 aggr->val += count->val; 248 aggr->val += count->val;
249 if (scale) { 249 if (stat_config.scale) {
250 aggr->ena += count->ena; 250 aggr->ena += count->ena;
251 aggr->run += count->run; 251 aggr->run += count->run;
252 } 252 }
@@ -299,7 +299,7 @@ static int process_counter(struct perf_evsel *counter)
299 299
300 if (!counter->snapshot) 300 if (!counter->snapshot)
301 perf_evsel__compute_deltas(counter, -1, -1, aggr); 301 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);
303 303
304 for (i = 0; i < 3; i++) 304 for (i = 0; i < 3; i++)
305 update_stats(&ps->res_stats[i], count[i]); 305 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)
1274 "system-wide collection from all CPUs"), 1274 "system-wide collection from all CPUs"),
1275 OPT_BOOLEAN('g', "group", &group, 1275 OPT_BOOLEAN('g', "group", &group,
1276 "put the counters into a counter group"), 1276 "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"),
1278 OPT_INCR('v', "verbose", &verbose, 1278 OPT_INCR('v', "verbose", &verbose,
1279 "be more verbose (show counter open errors, etc)"), 1279 "be more verbose (show counter open errors, etc)"),
1280 OPT_INTEGER('r', "repeat", &run_count, 1280 OPT_INTEGER('r', "repeat", &run_count,
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 078bee49ccad..0a1d83faa7b9 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -52,6 +52,7 @@ struct perf_counts {
52 52
53struct perf_stat_config { 53struct perf_stat_config {
54 enum aggr_mode aggr_mode; 54 enum aggr_mode aggr_mode;
55 bool scale;
55}; 56};
56 57
57static inline struct perf_counts_values* 58static inline struct perf_counts_values*