Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf stat: Pass 'struct perf_stat_config' into process_counter()

Passing 'struct perf_stat_config' into process_counter(), so that we can
make process_counter() non static and use it from other places.

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-7-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
5e5fe748 ec0d3d1f

+16 -13
+16 -13
tools/perf/builtin-stat.c
··· 216 216 } 217 217 218 218 static int 219 - process_counter_values(struct perf_evsel *evsel, int cpu, int thread, 219 + process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel, 220 + int cpu, int thread, 220 221 struct perf_counts_values *count) 221 222 { 222 223 struct perf_counts_values *aggr = &evsel->counts->aggr; ··· 232 231 if (skip) 233 232 count = &zero; 234 233 235 - switch (stat_config.aggr_mode) { 234 + switch (config->aggr_mode) { 236 235 case AGGR_THREAD: 237 236 case AGGR_CORE: 238 237 case AGGR_SOCKET: 239 238 case AGGR_NONE: 240 239 if (!evsel->snapshot) 241 240 perf_evsel__compute_deltas(evsel, cpu, thread, count); 242 - perf_counts_values__scale(count, stat_config.scale, NULL); 243 - if (stat_config.aggr_mode == AGGR_NONE) 241 + perf_counts_values__scale(count, config->scale, NULL); 242 + if (config->aggr_mode == AGGR_NONE) 244 243 perf_stat__update_shadow_stats(evsel, count->values, cpu); 245 244 break; 246 245 case AGGR_GLOBAL: 247 246 aggr->val += count->val; 248 - if (stat_config.scale) { 247 + if (config->scale) { 249 248 aggr->ena += count->ena; 250 249 aggr->run += count->run; 251 250 } ··· 256 255 return 0; 257 256 } 258 257 259 - static int process_counter_maps(struct perf_evsel *counter) 258 + static int process_counter_maps(struct perf_stat_config *config, 259 + struct perf_evsel *counter) 260 260 { 261 261 int nthreads = thread_map__nr(counter->threads); 262 262 int ncpus = perf_evsel__nr_cpus(counter); ··· 268 266 269 267 for (thread = 0; thread < nthreads; thread++) { 270 268 for (cpu = 0; cpu < ncpus; cpu++) { 271 - if (process_counter_values(counter, cpu, thread, 269 + if (process_counter_values(config, counter, cpu, thread, 272 270 perf_counts(counter->counts, cpu, thread))) 273 271 return -1; 274 272 } ··· 277 275 return 0; 278 276 } 279 277 280 - static int process_counter(struct perf_evsel *counter) 278 + static int process_counter(struct perf_stat_config *config, 279 + struct perf_evsel *counter) 281 280 { 282 281 struct perf_counts_values *aggr = &counter->counts->aggr; 283 282 struct perf_stat *ps = counter->priv; ··· 291 288 if (counter->per_pkg) 292 289 zero_per_pkg(counter); 293 290 294 - ret = process_counter_maps(counter); 291 + ret = process_counter_maps(&stat_config, counter); 295 292 if (ret) 296 293 return ret; 297 294 298 - if (stat_config.aggr_mode != AGGR_GLOBAL) 295 + if (config->aggr_mode != AGGR_GLOBAL) 299 296 return 0; 300 297 301 298 if (!counter->snapshot) 302 299 perf_evsel__compute_deltas(counter, -1, -1, aggr); 303 - perf_counts_values__scale(aggr, stat_config.scale, &counter->counts->scaled); 300 + perf_counts_values__scale(aggr, config->scale, &counter->counts->scaled); 304 301 305 302 for (i = 0; i < 3; i++) 306 303 update_stats(&ps->res_stats[i], count[i]); 307 304 308 305 if (verbose) { 309 - fprintf(stat_config.output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n", 306 + fprintf(config->output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n", 310 307 perf_evsel__name(counter), count[0], count[1], count[2]); 311 308 } 312 309 ··· 355 352 if (read_counter(counter)) 356 353 pr_warning("failed to read counter %s\n", counter->name); 357 354 358 - if (process_counter(counter)) 355 + if (process_counter(&stat_config, counter)) 359 356 pr_warning("failed to process counter %s\n", counter->name); 360 357 361 358 if (close_counters) {