mirror of
https://github.com/torvalds/linux.git
synced 2026-11-24 07:22:34 +00:00
A common problem is confusing CPU map indices with the CPU, by wrapping the CPU with a struct then this is avoided. This approach is similar to atomic_t. Committer notes: To make it build with BUILD_BPF_SKEL=1 these files needed the conversions to 'struct perf_cpu' usage: tools/perf/util/bpf_counter.c tools/perf/util/bpf_counter_cgroup.c tools/perf/util/bpf_ftrace.c Also perf_env__get_cpu() was removed back in "perf cpumap: Switch cpu_map__build_map to cpu function". Additionally these needed to be fixed for the ARM builds to complete: tools/perf/arch/arm/util/cs-etm.c tools/perf/arch/arm64/util/pmu.c Suggested-by: John Garry <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Clarke <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Riccardo Mancini <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Suzuki Poulouse <[email protected]> Cc: Vineet Singh <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
60 lines
1.5 KiB
C
60 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __LIBPERF_INTERNAL_MMAP_H
|
|
#define __LIBPERF_INTERNAL_MMAP_H
|
|
|
|
#include <linux/compiler.h>
|
|
#include <linux/refcount.h>
|
|
#include <linux/types.h>
|
|
#include <stdbool.h>
|
|
#include <internal/cpumap.h>
|
|
|
|
/* perf sample has 16 bits size limit */
|
|
#define PERF_SAMPLE_MAX_SIZE (1 << 16)
|
|
|
|
struct perf_mmap;
|
|
struct perf_counts_values;
|
|
|
|
typedef void (*libperf_unmap_cb_t)(struct perf_mmap *map);
|
|
|
|
/**
|
|
* struct perf_mmap - perf's ring buffer mmap details
|
|
*
|
|
* @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
|
|
*/
|
|
struct perf_mmap {
|
|
void *base;
|
|
int mask;
|
|
int fd;
|
|
struct perf_cpu cpu;
|
|
refcount_t refcnt;
|
|
u64 prev;
|
|
u64 start;
|
|
u64 end;
|
|
bool overwrite;
|
|
u64 flush;
|
|
libperf_unmap_cb_t unmap_cb;
|
|
char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
|
|
struct perf_mmap *next;
|
|
};
|
|
|
|
struct perf_mmap_param {
|
|
int prot;
|
|
int mask;
|
|
};
|
|
|
|
size_t perf_mmap__mmap_len(struct perf_mmap *map);
|
|
|
|
void perf_mmap__init(struct perf_mmap *map, struct perf_mmap *prev,
|
|
bool overwrite, libperf_unmap_cb_t unmap_cb);
|
|
int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp,
|
|
int fd, struct perf_cpu cpu);
|
|
void perf_mmap__munmap(struct perf_mmap *map);
|
|
void perf_mmap__get(struct perf_mmap *map);
|
|
void perf_mmap__put(struct perf_mmap *map);
|
|
|
|
u64 perf_mmap__read_head(struct perf_mmap *map);
|
|
|
|
int perf_mmap__read_self(struct perf_mmap *map, struct perf_counts_values *count);
|
|
|
|
#endif /* __LIBPERF_INTERNAL_MMAP_H */
|