perf stat: Don't call perf_stat_evsel_id_init() repeatedly
authorNamhyung Kim <namhyung@kernel.org>
Fri, 30 Sep 2022 20:21:05 +0000 (13:21 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 6 Oct 2022 11:03:53 +0000 (08:03 -0300)
evsel__reset_stat_priv() is called more than once if user gave -r option
for multiple runs.  But it doesn't need to re-initialize the id.

Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20220930202110.845199-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/stat.c

index 8d27ba77f8ab07c772733058e5d553baa631342d..7e9543cff31cfb30cd8716fba54124b493c3f81c 100644 (file)
@@ -135,7 +135,6 @@ static void evsel__reset_stat_priv(struct evsel *evsel)
        struct perf_stat_evsel *ps = evsel->stats;
 
        init_stats(&ps->res_stats);
-       perf_stat_evsel_id_init(evsel);
 }
 
 static int evsel__alloc_stat_priv(struct evsel *evsel)
@@ -143,6 +142,7 @@ static int evsel__alloc_stat_priv(struct evsel *evsel)
        evsel->stats = zalloc(sizeof(struct perf_stat_evsel));
        if (evsel->stats == NULL)
                return -ENOMEM;
+       perf_stat_evsel_id_init(evsel);
        evsel__reset_stat_priv(evsel);
        return 0;
 }