perf cpumap: Remove refcnt from 'struct cpu_aggr_map'
authorIan Rogers <irogers@google.com>
Tue, 7 May 2024 18:35:41 +0000 (11:35 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 7 May 2024 21:06:44 +0000 (18:06 -0300)
It is assigned a value of 1 and never incremented. Remove and replace
puts with delete.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ben Gainey <ben.gainey@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Li Dong <lidong@vivo.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: Paran Lee <p4ranlee@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sun Haiyong <sunhaiyong@loongson.cn>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Yanteng Si <siyanteng@loongson.cn>
Cc: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/20240507183545.1236093-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-stat.c
tools/perf/util/cpumap.c
tools/perf/util/cpumap.h

index 65a3dd7ffac30c229a5d4d5591756fc631d9ec6f..35f79b48e8dc9b0b2cce72f30e660f3952487e4f 100644 (file)
@@ -1631,23 +1631,13 @@ static int perf_stat_init_aggr_mode(void)
 
 static void cpu_aggr_map__delete(struct cpu_aggr_map *map)
 {
-       if (map) {
-               WARN_ONCE(refcount_read(&map->refcnt) != 0,
-                         "cpu_aggr_map refcnt unbalanced\n");
-               free(map);
-       }
-}
-
-static void cpu_aggr_map__put(struct cpu_aggr_map *map)
-{
-       if (map && refcount_dec_and_test(&map->refcnt))
-               cpu_aggr_map__delete(map);
+       free(map);
 }
 
 static void perf_stat__exit_aggr_mode(void)
 {
-       cpu_aggr_map__put(stat_config.aggr_map);
-       cpu_aggr_map__put(stat_config.cpus_aggr_map);
+       cpu_aggr_map__delete(stat_config.aggr_map);
+       cpu_aggr_map__delete(stat_config.cpus_aggr_map);
        stat_config.aggr_map = NULL;
        stat_config.cpus_aggr_map = NULL;
 }
index 6a270d640acb906118e1eba431864be8db9935b2..27094211edd8a8a9bff8cd9a200ad0ffd8df5dc5 100644 (file)
@@ -180,8 +180,6 @@ struct cpu_aggr_map *cpu_aggr_map__empty_new(int nr)
                cpus->nr = nr;
                for (i = 0; i < nr; i++)
                        cpus->map[i] = aggr_cpu_id__empty();
-
-               refcount_set(&cpus->refcnt, 1);
        }
 
        return cpus;
index 26cf76c693f5ea3e6861f727126f731f92e33525..ee0f6139b04a1cb5ae884f095794974b1b7a8ff9 100644 (file)
@@ -5,7 +5,6 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <perf/cpumap.h>
-#include <linux/refcount.h>
 
 /** Identify where counts are aggregated, -1 implies not to aggregate. */
 struct aggr_cpu_id {
@@ -37,7 +36,6 @@ struct aggr_cpu_id {
 
 /** A collection of aggr_cpu_id values, the "built" version is sorted and uniqued. */
 struct cpu_aggr_map {
-       refcount_t refcnt;
        /** Number of valid entries. */
        int nr;
        /** The entries. */