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

perf stat: Remove unused perf_counts.aggr field

The aggr field in the struct perf_counts is to keep the aggregated value
in the AGGR_GLOBAL for the old code. But it's not used anymore.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20221018020227.85905-21-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
8b76a318 cec94d69

+6 -35
-1
tools/perf/util/counts.c
··· 48 48 { 49 49 xyarray__reset(counts->loaded); 50 50 xyarray__reset(counts->values); 51 - memset(&counts->aggr, 0, sizeof(struct perf_counts_values)); 52 51 } 53 52 54 53 void evsel__reset_counts(struct evsel *evsel)
-1
tools/perf/util/counts.h
··· 11 11 12 12 struct perf_counts { 13 13 s8 scaled; 14 - struct perf_counts_values aggr; 15 14 struct xyarray *values; 16 15 struct xyarray *loaded; 17 16 };
+6 -33
tools/perf/util/stat.c
··· 308 308 *perf_counts(evsel->prev_raw_counts, idx, thread); 309 309 } 310 310 } 311 - 312 - evsel->counts->aggr = evsel->prev_raw_counts->aggr; 313 311 } 314 312 315 313 void evlist__copy_prev_raw_counts(struct evlist *evlist) ··· 316 318 317 319 evlist__for_each_entry(evlist, evsel) 318 320 evsel__copy_prev_raw_counts(evsel); 319 - } 320 - 321 - void evlist__save_aggr_prev_raw_counts(struct evlist *evlist) 322 - { 323 - struct evsel *evsel; 324 - 325 - /* 326 - * To collect the overall statistics for interval mode, 327 - * we copy the counts from evsel->prev_raw_counts to 328 - * evsel->counts. The perf_stat_process_counter creates 329 - * aggr values from per cpu values, but the per cpu values 330 - * are 0 for AGGR_GLOBAL. So we use a trick that saves the 331 - * previous aggr value to the first member of perf_counts, 332 - * then aggr calculation in process_counter_values can work 333 - * correctly. 334 - */ 335 - evlist__for_each_entry(evlist, evsel) { 336 - *perf_counts(evsel->prev_raw_counts, 0, 0) = 337 - evsel->prev_raw_counts->aggr; 338 - } 339 321 } 340 322 341 323 static size_t pkg_id_hash(const void *__key, void *ctx __maybe_unused) ··· 420 442 int cpu_map_idx, int thread, 421 443 struct perf_counts_values *count) 422 444 { 423 - struct perf_counts_values *aggr = &evsel->counts->aggr; 424 445 struct perf_stat_evsel *ps = evsel->stats; 425 446 static struct perf_counts_values zero; 426 447 bool skip = false; ··· 488 511 } 489 512 } 490 513 491 - if (config->aggr_mode == AGGR_GLOBAL) { 492 - aggr->val += count->val; 493 - aggr->ena += count->ena; 494 - aggr->run += count->run; 495 - } 496 - 497 514 return 0; 498 515 } 499 516 ··· 512 541 int perf_stat_process_counter(struct perf_stat_config *config, 513 542 struct evsel *counter) 514 543 { 515 - struct perf_counts_values *aggr = &counter->counts->aggr; 516 544 struct perf_stat_evsel *ps = counter->stats; 517 - u64 *count = counter->counts->aggr.values; 545 + u64 *count; 518 546 int ret; 519 - 520 - aggr->val = aggr->ena = aggr->run = 0; 521 547 522 548 if (counter->per_pkg) 523 549 evsel__zero_per_pkg(counter); ··· 526 558 if (config->aggr_mode != AGGR_GLOBAL) 527 559 return 0; 528 560 561 + /* 562 + * GLOBAL aggregation mode only has a single aggr counts, 563 + * so we can use ps->aggr[0] as the actual output. 564 + */ 565 + count = ps->aggr[0].counts.values; 529 566 update_stats(&ps->res_stats, *count); 530 567 531 568 if (verbose > 0) {