It uses only one member, no need to have it as an array.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/stat-display.c | 2 +-
tools/perf/util/stat.c | 10 +++-------
tools/perf/util/stat.h | 2 +-
3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index b82844cb0ce7..234491f43c36 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -67,7 +67,7 @@ static void print_noise(struct perf_stat_config *config,
return;
ps = evsel->stats;
- print_noise_pct(config, stddev_stats(&ps->res_stats[0]), avg);
+ print_noise_pct(config, stddev_stats(&ps->res_stats), avg);
}
static void print_cgroup(struct perf_stat_config *config, struct evsel *evsel)
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index ce5e9e372fc4..6bcd3dc32a71 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -132,12 +132,9 @@ static void perf_stat_evsel_id_init(struct evsel *evsel)
static void evsel__reset_stat_priv(struct evsel *evsel)
{
- int i;
struct perf_stat_evsel *ps = evsel->stats;
- for (i = 0; i < 3; i++)
- init_stats(&ps->res_stats[i]);
-
+ init_stats(&ps->res_stats);
perf_stat_evsel_id_init(evsel);
}
@@ -440,7 +437,7 @@ int perf_stat_process_counter(struct perf_stat_config *config,
struct perf_counts_values *aggr = &counter->counts->aggr;
struct perf_stat_evsel *ps = counter->stats;
u64 *count = counter->counts->aggr.values;
- int i, ret;
+ int ret;
aggr->val = aggr->ena = aggr->run = 0;
@@ -458,8 +455,7 @@ int perf_stat_process_counter(struct perf_stat_config *config,
evsel__compute_deltas(counter, -1, -1, aggr);
perf_counts_values__scale(aggr, config->scale, &counter->counts->scaled);
- for (i = 0; i < 3; i++)
- update_stats(&ps->res_stats[i], count[i]);
+ update_stats(&ps->res_stats, *count);
if (verbose > 0) {
fprintf(config->output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 72713b344b79..3eba38a1a149 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -43,7 +43,7 @@ enum perf_stat_evsel_id {
};
struct perf_stat_evsel {
- struct stats res_stats[3];
+ struct stats res_stats;
enum perf_stat_evsel_id id;
u64 *group_data;
};
--
2.37.3.998.g577e59143f-goog
On 26/09/2022 21:07, Namhyung Kim wrote:
> It uses only one member, no need to have it as an array.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/util/stat-display.c | 2 +-
> tools/perf/util/stat.c | 10 +++-------
> tools/perf/util/stat.h | 2 +-
> 3 files changed, 5 insertions(+), 9 deletions(-)
>
Reviewed-by: James Clark <james.clark@arm.com>
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index b82844cb0ce7..234491f43c36 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -67,7 +67,7 @@ static void print_noise(struct perf_stat_config *config,
> return;
>
> ps = evsel->stats;
> - print_noise_pct(config, stddev_stats(&ps->res_stats[0]), avg);
> + print_noise_pct(config, stddev_stats(&ps->res_stats), avg);
> }
>
> static void print_cgroup(struct perf_stat_config *config, struct evsel *evsel)
> diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
> index ce5e9e372fc4..6bcd3dc32a71 100644
> --- a/tools/perf/util/stat.c
> +++ b/tools/perf/util/stat.c
> @@ -132,12 +132,9 @@ static void perf_stat_evsel_id_init(struct evsel *evsel)
>
> static void evsel__reset_stat_priv(struct evsel *evsel)
> {
> - int i;
> struct perf_stat_evsel *ps = evsel->stats;
>
> - for (i = 0; i < 3; i++)
> - init_stats(&ps->res_stats[i]);
> -
> + init_stats(&ps->res_stats);
> perf_stat_evsel_id_init(evsel);
> }
>
> @@ -440,7 +437,7 @@ int perf_stat_process_counter(struct perf_stat_config *config,
> struct perf_counts_values *aggr = &counter->counts->aggr;
> struct perf_stat_evsel *ps = counter->stats;
> u64 *count = counter->counts->aggr.values;
> - int i, ret;
> + int ret;
>
> aggr->val = aggr->ena = aggr->run = 0;
>
> @@ -458,8 +455,7 @@ int perf_stat_process_counter(struct perf_stat_config *config,
> evsel__compute_deltas(counter, -1, -1, aggr);
> perf_counts_values__scale(aggr, config->scale, &counter->counts->scaled);
>
> - for (i = 0; i < 3; i++)
> - update_stats(&ps->res_stats[i], count[i]);
> + update_stats(&ps->res_stats, *count);
>
> if (verbose > 0) {
> fprintf(config->output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
> diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
> index 72713b344b79..3eba38a1a149 100644
> --- a/tools/perf/util/stat.h
> +++ b/tools/perf/util/stat.h
> @@ -43,7 +43,7 @@ enum perf_stat_evsel_id {
> };
>
> struct perf_stat_evsel {
> - struct stats res_stats[3];
> + struct stats res_stats;
> enum perf_stat_evsel_id id;
> u64 *group_data;
> };
© 2016 - 2026 Red Hat, Inc.