Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __LIBPERF_INTERNAL_EVSEL_H
0003 #define __LIBPERF_INTERNAL_EVSEL_H
0004 
0005 #include <linux/types.h>
0006 #include <linux/perf_event.h>
0007 #include <stdbool.h>
0008 #include <sys/types.h>
0009 #include <internal/cpumap.h>
0010 
0011 struct perf_thread_map;
0012 struct xyarray;
0013 
0014 /*
0015  * Per fd, to map back from PERF_SAMPLE_ID to evsel, only used when there are
0016  * more than one entry in the evlist.
0017  */
0018 struct perf_sample_id {
0019     struct hlist_node    node;
0020     u64          id;
0021     struct perf_evsel   *evsel;
0022        /*
0023     * 'idx' will be used for AUX area sampling. A sample will have AUX area
0024     * data that will be queued for decoding, where there are separate
0025     * queues for each CPU (per-cpu tracing) or task (per-thread tracing).
0026     * The sample ID can be used to lookup 'idx' which is effectively the
0027     * queue number.
0028     */
0029     int          idx;
0030     struct perf_cpu      cpu;
0031     pid_t            tid;
0032 
0033     /* Guest machine pid and VCPU, valid only if machine_pid is non-zero */
0034     pid_t            machine_pid;
0035     struct perf_cpu      vcpu;
0036 
0037     /* Holds total ID period value for PERF_SAMPLE_READ processing. */
0038     u64          period;
0039 };
0040 
0041 struct perf_evsel {
0042     struct list_head     node;
0043     struct perf_event_attr   attr;
0044     struct perf_cpu_map *cpus;
0045     struct perf_cpu_map *own_cpus;
0046     struct perf_thread_map  *threads;
0047     struct xyarray      *fd;
0048     struct xyarray      *mmap;
0049     struct xyarray      *sample_id;
0050     u64         *id;
0051     u32          ids;
0052     struct perf_evsel   *leader;
0053 
0054     /* parse modifier helper */
0055     int          nr_members;
0056     /*
0057      * system_wide is for events that need to be on every CPU, irrespective
0058      * of user requested CPUs or threads. Map propagation will set cpus to
0059      * this event's own_cpus, whereby they will contribute to evlist
0060      * all_cpus.
0061      */
0062     bool             system_wide;
0063     /*
0064      * Some events, for example uncore events, require a CPU.
0065      * i.e. it cannot be the 'any CPU' value of -1.
0066      */
0067     bool             requires_cpu;
0068     int          idx;
0069 };
0070 
0071 void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr,
0072               int idx);
0073 int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
0074 void perf_evsel__close_fd(struct perf_evsel *evsel);
0075 void perf_evsel__free_fd(struct perf_evsel *evsel);
0076 int perf_evsel__read_size(struct perf_evsel *evsel);
0077 int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter);
0078 
0079 int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
0080 void perf_evsel__free_id(struct perf_evsel *evsel);
0081 
0082 #endif /* __LIBPERF_INTERNAL_EVSEL_H */