perf cpumap: Add new map type for aggregation
authorJames Clark <james.clark@arm.com>
Thu, 26 Nov 2020 14:13:21 +0000 (16:13 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 24 Dec 2020 13:04:24 +0000 (10:04 -0300)
Currently this is a duplicate of perf_cpu_map so that it can be used as
a drop in replacement.

In a later commit it will be changed from a map of ints to use the new
cpu_aggr_id struct.

No functional changes.

Signed-off-by: James Clark <james.clark@arm.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: John Garry <john.garry@huawei.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Link: https://lore.kernel.org/r/20201126141328.6509-6-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/cpumap.c
tools/perf/util/cpumap.h

index e05a12b..b18e535 100644 (file)
@@ -95,6 +95,23 @@ struct perf_cpu_map *perf_cpu_map__empty_new(int nr)
        return cpus;
 }
 
+struct cpu_aggr_map *cpu_aggr_map__empty_new(int nr)
+{
+       struct cpu_aggr_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr);
+
+       if (cpus != NULL) {
+               int i;
+
+               cpus->nr = nr;
+               for (i = 0; i < nr; i++)
+                       cpus->map[i] = -1;
+
+               refcount_set(&cpus->refcnt, 1);
+       }
+
+       return cpus;
+}
+
 static int cpu__get_topology_int(int cpu, const char *name, int *value)
 {
        char path[PATH_MAX];
index b8c2288..ebd65c4 100644 (file)
@@ -11,9 +11,17 @@ struct aggr_cpu_id {
        int id;
 };
 
+struct cpu_aggr_map {
+       refcount_t refcnt;
+       int nr;
+       int map[];
+};
+
 struct perf_record_cpu_map_data;
 
 struct perf_cpu_map *perf_cpu_map__empty_new(int nr);
+struct cpu_aggr_map *cpu_aggr_map__empty_new(int nr);
+
 struct perf_cpu_map *cpu_map__new_data(struct perf_record_cpu_map_data *data);
 size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size);
 size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size);