evlist contains cpus and all_cpus. all_cpus is the union of the cpu maps of all evsels. For non-task targets, cpus is set to be cpus requested from the command line, defaulting to all online cpus if no cpus are specified. For an uncore event, all_cpus may be just CPU 0 or every online CPU. This causes all_cpus to have fewer values than the cpus variable which is confusing given the 'all' in the name. To try to make the behavior clearer, rename cpus to user_requested_cpus and add comments on the two struct variables. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Antonov <alexander.antonov@linux.intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrii Nakryiko <andrii@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: German Gomez <german.gomez@arm.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Fastabend <john.fastabend@gmail.com> Cc: John Garry <john.garry@huawei.com> Cc: KP Singh <kpsingh@kernel.org> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Martin KaFai Lau <kafai@fb.com> Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Riccardo Mancini <rickyman7@gmail.com> Cc: Song Liu <songliubraving@fb.com> Cc: Stephane Eranian <eranian@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Yonghong Song <yhs@fb.com> Cc: bpf@vger.kernel.org Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Cc: netdev@vger.kernel.org Link: http://lore.kernel.org/lkml/20220328232648.2127340-3-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
137 lines
4.2 KiB
C
137 lines
4.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __LIBPERF_INTERNAL_EVLIST_H
|
|
#define __LIBPERF_INTERNAL_EVLIST_H
|
|
|
|
#include <linux/list.h>
|
|
#include <api/fd/array.h>
|
|
#include <internal/cpumap.h>
|
|
#include <internal/evsel.h>
|
|
|
|
#define PERF_EVLIST__HLIST_BITS 8
|
|
#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
|
|
|
|
struct perf_cpu_map;
|
|
struct perf_thread_map;
|
|
struct perf_mmap_param;
|
|
|
|
struct perf_evlist {
|
|
struct list_head entries;
|
|
int nr_entries;
|
|
int nr_groups;
|
|
bool has_user_cpus;
|
|
/**
|
|
* The cpus passed from the command line or all online CPUs by
|
|
* default.
|
|
*/
|
|
struct perf_cpu_map *user_requested_cpus;
|
|
/** The union of all evsel cpu maps. */
|
|
struct perf_cpu_map *all_cpus;
|
|
struct perf_thread_map *threads;
|
|
int nr_mmaps;
|
|
size_t mmap_len;
|
|
struct fdarray pollfd;
|
|
struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
|
|
struct perf_mmap *mmap;
|
|
struct perf_mmap *mmap_ovw;
|
|
struct perf_mmap *mmap_first;
|
|
struct perf_mmap *mmap_ovw_first;
|
|
};
|
|
|
|
typedef void
|
|
(*perf_evlist_mmap__cb_idx_t)(struct perf_evlist*, struct perf_mmap_param*, int, bool);
|
|
typedef struct perf_mmap*
|
|
(*perf_evlist_mmap__cb_get_t)(struct perf_evlist*, bool, int);
|
|
typedef int
|
|
(*perf_evlist_mmap__cb_mmap_t)(struct perf_mmap*, struct perf_mmap_param*, int, struct perf_cpu);
|
|
|
|
struct perf_evlist_mmap_ops {
|
|
perf_evlist_mmap__cb_idx_t idx;
|
|
perf_evlist_mmap__cb_get_t get;
|
|
perf_evlist_mmap__cb_mmap_t mmap;
|
|
};
|
|
|
|
int perf_evlist__alloc_pollfd(struct perf_evlist *evlist);
|
|
int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd,
|
|
void *ptr, short revent, enum fdarray_flags flags);
|
|
|
|
int perf_evlist__mmap_ops(struct perf_evlist *evlist,
|
|
struct perf_evlist_mmap_ops *ops,
|
|
struct perf_mmap_param *mp);
|
|
|
|
void perf_evlist__init(struct perf_evlist *evlist);
|
|
void perf_evlist__exit(struct perf_evlist *evlist);
|
|
|
|
/**
|
|
* __perf_evlist__for_each_entry - iterate thru all the evsels
|
|
* @list: list_head instance to iterate
|
|
* @evsel: struct perf_evsel iterator
|
|
*/
|
|
#define __perf_evlist__for_each_entry(list, evsel) \
|
|
list_for_each_entry(evsel, list, node)
|
|
|
|
/**
|
|
* evlist__for_each_entry - iterate thru all the evsels
|
|
* @evlist: perf_evlist instance to iterate
|
|
* @evsel: struct perf_evsel iterator
|
|
*/
|
|
#define perf_evlist__for_each_entry(evlist, evsel) \
|
|
__perf_evlist__for_each_entry(&(evlist)->entries, evsel)
|
|
|
|
/**
|
|
* __perf_evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
|
|
* @list: list_head instance to iterate
|
|
* @evsel: struct evsel iterator
|
|
*/
|
|
#define __perf_evlist__for_each_entry_reverse(list, evsel) \
|
|
list_for_each_entry_reverse(evsel, list, node)
|
|
|
|
/**
|
|
* perf_evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
|
|
* @evlist: evlist instance to iterate
|
|
* @evsel: struct evsel iterator
|
|
*/
|
|
#define perf_evlist__for_each_entry_reverse(evlist, evsel) \
|
|
__perf_evlist__for_each_entry_reverse(&(evlist)->entries, evsel)
|
|
|
|
/**
|
|
* __perf_evlist__for_each_entry_safe - safely iterate thru all the evsels
|
|
* @list: list_head instance to iterate
|
|
* @tmp: struct evsel temp iterator
|
|
* @evsel: struct evsel iterator
|
|
*/
|
|
#define __perf_evlist__for_each_entry_safe(list, tmp, evsel) \
|
|
list_for_each_entry_safe(evsel, tmp, list, node)
|
|
|
|
/**
|
|
* perf_evlist__for_each_entry_safe - safely iterate thru all the evsels
|
|
* @evlist: evlist instance to iterate
|
|
* @evsel: struct evsel iterator
|
|
* @tmp: struct evsel temp iterator
|
|
*/
|
|
#define perf_evlist__for_each_entry_safe(evlist, tmp, evsel) \
|
|
__perf_evlist__for_each_entry_safe(&(evlist)->entries, tmp, evsel)
|
|
|
|
static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist)
|
|
{
|
|
return list_entry(evlist->entries.next, struct perf_evsel, node);
|
|
}
|
|
|
|
static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist)
|
|
{
|
|
return list_entry(evlist->entries.prev, struct perf_evsel, node);
|
|
}
|
|
|
|
u64 perf_evlist__read_format(struct perf_evlist *evlist);
|
|
|
|
void perf_evlist__id_add(struct perf_evlist *evlist,
|
|
struct perf_evsel *evsel,
|
|
int cpu, int thread, u64 id);
|
|
|
|
int perf_evlist__id_add_fd(struct perf_evlist *evlist,
|
|
struct perf_evsel *evsel,
|
|
int cpu, int thread, int fd);
|
|
|
|
void perf_evlist__reset_id_hash(struct perf_evlist *evlist);
|
|
|
|
void __perf_evlist__set_leader(struct list_head *list, struct perf_evsel *leader);
|
|
#endif /* __LIBPERF_INTERNAL_EVLIST_H */
|