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

perf stat: Reduce scope of walltime_nsecs_stats

walltime_nsecs_stats is no longer used for counter values, move into
that stat_config where it controls certain things like noise
measurement.

Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
d702c0f4 557c3443

+10 -21
+8 -8
tools/perf/builtin-stat.c
··· 239 239 static void perf_stat__reset_stats(void) 240 240 { 241 241 evlist__reset_stats(evsel_list); 242 - perf_stat__reset_shadow_stats(); 242 + memset(stat_config.walltime_nsecs_stats, 0, sizeof(*stat_config.walltime_nsecs_stats)); 243 243 } 244 244 245 245 static int process_synthesized_event(const struct perf_tool *tool __maybe_unused, ··· 455 455 pr_err("failed to write stat round event\n"); 456 456 } 457 457 458 - init_stats(&walltime_nsecs_stats); 459 - update_stats(&walltime_nsecs_stats, stat_config.interval * 1000000ULL); 458 + init_stats(stat_config.walltime_nsecs_stats); 459 + update_stats(stat_config.walltime_nsecs_stats, stat_config.interval * 1000000ULL); 460 460 print_counters(&rs, 0, NULL); 461 461 } 462 462 ··· 988 988 if (interval && stat_config.summary) { 989 989 stat_config.interval = 0; 990 990 stat_config.stop_read_counter = true; 991 - init_stats(&walltime_nsecs_stats); 992 - update_stats(&walltime_nsecs_stats, t1 - t0); 991 + init_stats(stat_config.walltime_nsecs_stats); 992 + update_stats(stat_config.walltime_nsecs_stats, t1 - t0); 993 993 994 994 evlist__copy_prev_raw_counts(evsel_list); 995 995 evlist__reset_prev_raw_counts(evsel_list); 996 996 evlist__reset_aggr_stats(evsel_list); 997 997 } else { 998 - update_stats(&walltime_nsecs_stats, t1 - t0); 998 + update_stats(stat_config.walltime_nsecs_stats, t1 - t0); 999 999 update_rusage_stats(&stat_config.ru_data); 1000 1000 } 1001 1001 ··· 2167 2167 process_counters(); 2168 2168 2169 2169 if (stat_round->type == PERF_STAT_ROUND_TYPE__FINAL) 2170 - update_stats(&walltime_nsecs_stats, stat_round->time); 2170 + update_stats(stat_config.walltime_nsecs_stats, stat_round->time); 2171 2171 2172 2172 if (stat_config.interval && stat_round->time) { 2173 2173 tsh.tv_sec = stat_round->time / NSEC_PER_SEC; ··· 2975 2975 } 2976 2976 2977 2977 if (!interval) { 2978 - if (WRITE_STAT_ROUND_EVENT(walltime_nsecs_stats.max, FINAL)) 2978 + if (WRITE_STAT_ROUND_EVENT(stat_config.walltime_nsecs_stats->max, FINAL)) 2979 2979 pr_err("failed to write stat round event\n"); 2980 2980 } 2981 2981
-2
tools/perf/tests/parse-metric.c
··· 41 41 count = find_value(evsel->name, vals); 42 42 evsel->supported = true; 43 43 evsel->stats->aggr->counts.val = count; 44 - if (evsel__name_is(evsel, "duration_time")) 45 - update_stats(&walltime_nsecs_stats, count); 46 44 } 47 45 } 48 46
-2
tools/perf/tests/pmu-events.c
··· 872 872 evlist__alloc_aggr_stats(evlist, 1); 873 873 evlist__for_each_entry(evlist, evsel) { 874 874 evsel->stats->aggr->counts.val = k; 875 - if (evsel__name_is(evsel, "duration_time")) 876 - update_stats(&walltime_nsecs_stats, k); 877 875 k++; 878 876 } 879 877 evlist__for_each_entry(evlist, evsel) {
+2
tools/perf/util/config.c
··· 37 37 38 38 #define METRIC_ONLY_LEN 20 39 39 40 + static struct stats walltime_nsecs_stats; 41 + 40 42 struct perf_stat_config stat_config = { 41 43 .aggr_mode = AGGR_GLOBAL, 42 44 .aggr_level = MAX_CACHE_LVL + 1,
-7
tools/perf/util/stat-shadow.c
··· 18 18 #include "util/hashmap.h" 19 19 #include "tool_pmu.h" 20 20 21 - struct stats walltime_nsecs_stats; 22 - 23 - void perf_stat__reset_shadow_stats(void) 24 - { 25 - memset(&walltime_nsecs_stats, 0, sizeof(walltime_nsecs_stats)); 26 - } 27 - 28 21 static bool tool_pmu__is_time_event(const struct perf_stat_config *config, 29 22 const struct evsel *evsel, int *tool_aggr_idx) 30 23 {
-2
tools/perf/util/stat.h
··· 129 129 struct evsel; 130 130 struct evlist; 131 131 132 - extern struct stats walltime_nsecs_stats; 133 - 134 132 enum metric_threshold_classify { 135 133 METRIC_THRESHOLD_UNKNOWN, 136 134 METRIC_THRESHOLD_BAD,