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

perf cpumap: Remove refcnt from 'struct cpu_aggr_map'

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>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
a8cd4766 557b32c3

+3 -17
+3 -13
tools/perf/builtin-stat.c
··· 1631 1631 1632 1632 static void cpu_aggr_map__delete(struct cpu_aggr_map *map) 1633 1633 { 1634 - if (map) { 1635 - WARN_ONCE(refcount_read(&map->refcnt) != 0, 1636 - "cpu_aggr_map refcnt unbalanced\n"); 1637 - free(map); 1638 - } 1639 - } 1640 - 1641 - static void cpu_aggr_map__put(struct cpu_aggr_map *map) 1642 - { 1643 - if (map && refcount_dec_and_test(&map->refcnt)) 1644 - cpu_aggr_map__delete(map); 1634 + free(map); 1645 1635 } 1646 1636 1647 1637 static void perf_stat__exit_aggr_mode(void) 1648 1638 { 1649 - cpu_aggr_map__put(stat_config.aggr_map); 1650 - cpu_aggr_map__put(stat_config.cpus_aggr_map); 1639 + cpu_aggr_map__delete(stat_config.aggr_map); 1640 + cpu_aggr_map__delete(stat_config.cpus_aggr_map); 1651 1641 stat_config.aggr_map = NULL; 1652 1642 stat_config.cpus_aggr_map = NULL; 1653 1643 }
-2
tools/perf/util/cpumap.c
··· 180 180 cpus->nr = nr; 181 181 for (i = 0; i < nr; i++) 182 182 cpus->map[i] = aggr_cpu_id__empty(); 183 - 184 - refcount_set(&cpus->refcnt, 1); 185 183 } 186 184 187 185 return cpus;
-2
tools/perf/util/cpumap.h
··· 5 5 #include <stdbool.h> 6 6 #include <stdio.h> 7 7 #include <perf/cpumap.h> 8 - #include <linux/refcount.h> 9 8 10 9 /** Identify where counts are aggregated, -1 implies not to aggregate. */ 11 10 struct aggr_cpu_id { ··· 36 37 37 38 /** A collection of aggr_cpu_id values, the "built" version is sorted and uniqued. */ 38 39 struct cpu_aggr_map { 39 - refcount_t refcnt; 40 40 /** Number of valid entries. */ 41 41 int nr; 42 42 /** The entries. */