5f50e15c15
Turn it into a cpu_aggr_map__new(). Pass helper functions. Refactor builtin-stat calls to manually pass function pointers. Try to reduce some copy-paste code. Reviewed-by: James Clark <james.clark@arm.com> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: John Garry <john.garry@huawei.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Clarke <pc@us.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Riccardo Mancini <rickyman7@gmail.com> Cc: Stephane Eranian <eranian@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Vineet Singh <vineet.singh@intel.com> Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Cc: zhengjun.xing@intel.com Link: https://lore.kernel.org/r/20220105061351.120843-19-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
92 lines
3.0 KiB
C
92 lines
3.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __PERF_CPUMAP_H
|
|
#define __PERF_CPUMAP_H
|
|
|
|
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
#include <internal/cpumap.h>
|
|
#include <perf/cpumap.h>
|
|
|
|
/** Identify where counts are aggregated, -1 implies not to aggregate. */
|
|
struct aggr_cpu_id {
|
|
/** A value in the range 0 to number of threads. */
|
|
int thread;
|
|
/** The numa node X as read from /sys/devices/system/node/nodeX. */
|
|
int node;
|
|
/**
|
|
* The socket number as read from
|
|
* /sys/devices/system/cpu/cpuX/topology/physical_package_id.
|
|
*/
|
|
int socket;
|
|
/** The die id as read from /sys/devices/system/cpu/cpuX/topology/die_id. */
|
|
int die;
|
|
/** The core id as read from /sys/devices/system/cpu/cpuX/topology/core_id. */
|
|
int core;
|
|
};
|
|
|
|
struct cpu_aggr_map {
|
|
refcount_t refcnt;
|
|
int nr;
|
|
struct aggr_cpu_id 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);
|
|
size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp);
|
|
struct aggr_cpu_id cpu_map__get_socket_aggr_by_cpu(int cpu, void *data);
|
|
struct aggr_cpu_id cpu_map__get_die_aggr_by_cpu(int cpu, void *data);
|
|
struct aggr_cpu_id cpu_map__get_core_aggr_by_cpu(int cpu, void *data);
|
|
struct aggr_cpu_id cpu_map__get_node_aggr_by_cpu(int cpu, void *data);
|
|
const struct perf_cpu_map *cpu_map__online(void); /* thread unsafe */
|
|
|
|
int cpu__setup_cpunode_map(void);
|
|
|
|
int cpu__max_node(void);
|
|
int cpu__max_cpu(void);
|
|
int cpu__max_present_cpu(void);
|
|
/**
|
|
* cpu__get_node - Returns the numa node X as read from
|
|
* /sys/devices/system/node/nodeX for the given CPU.
|
|
*/
|
|
int cpu__get_node(int cpu);
|
|
/**
|
|
* cpu__get_socket_id - Returns the socket number as read from
|
|
* /sys/devices/system/cpu/cpuX/topology/physical_package_id for the given CPU.
|
|
*/
|
|
int cpu__get_socket_id(int cpu);
|
|
/**
|
|
* cpu__get_die_id - Returns the die id as read from
|
|
* /sys/devices/system/cpu/cpuX/topology/die_id for the given CPU.
|
|
*/
|
|
int cpu__get_die_id(int cpu);
|
|
/**
|
|
* cpu__get_core_id - Returns the core id as read from
|
|
* /sys/devices/system/cpu/cpuX/topology/core_id for the given CPU.
|
|
*/
|
|
int cpu__get_core_id(int cpu);
|
|
|
|
typedef struct aggr_cpu_id (*aggr_cpu_id_get_t)(int cpu, void *data);
|
|
|
|
/**
|
|
* cpu_aggr_map__new - Create a cpu_aggr_map with an aggr_cpu_id for each cpu in
|
|
* cpus. The aggr_cpu_id is created with 'get_id' that may have a data value
|
|
* passed to it. The cpu_aggr_map is sorted with duplicate values removed.
|
|
*/
|
|
struct cpu_aggr_map *cpu_aggr_map__new(const struct perf_cpu_map *cpus,
|
|
aggr_cpu_id_get_t get_id,
|
|
void *data);
|
|
|
|
bool cpu_map__has(struct perf_cpu_map *cpus, int cpu);
|
|
|
|
bool aggr_cpu_id__equal(const struct aggr_cpu_id *a, const struct aggr_cpu_id *b);
|
|
bool aggr_cpu_id__is_empty(const struct aggr_cpu_id *a);
|
|
struct aggr_cpu_id aggr_cpu_id__empty(void);
|
|
|
|
#endif /* __PERF_CPUMAP_H */
|