^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __PERF_SYNTHETIC_EVENTS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __PERF_SYNTHETIC_EVENTS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <stdbool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <sys/types.h> // pid_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct auxtrace_record;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct dso;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct evlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct evsel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct machine;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct perf_counts_values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct perf_cpu_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct perf_event_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct perf_event_mmap_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct perf_sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct perf_session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct perf_stat_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct perf_thread_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct perf_tool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct record_opts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) union perf_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct perf_sample *sample, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16 misc, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) int perf_event__synthesize_cpu_map(struct perf_tool *tool, struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int perf_event__synthesize_event_update_name(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) int perf_event__synthesize_event_update_scale(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlist *evsel_list, perf_event__handler_t process, bool is_pipe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int perf_event__synthesize_features(struct perf_tool *tool, struct perf_session *session, struct evlist *evlist, perf_event__handler_t process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__handler_t process, struct evlist *evlist, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int perf_event__synthesize_mmap_events(struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct machine *machine, bool mmap_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) int perf_event__synthesize_namespaces(struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int perf_event__synthesize_cgroups(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 read_format, const struct perf_sample *sample);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int perf_event__synthesize_stat_config(struct perf_tool *tool, struct perf_stat_config *config, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) int perf_event__synthesize_stat_events(struct perf_stat_config *config, struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process, bool attrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int perf_event__synthesize_stat_round(struct perf_tool *tool, u64 time, u64 type, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int perf_event__synthesize_stat(struct perf_tool *tool, u32 cpu, u32 thread, u64 id, struct perf_counts_values *count, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) int perf_event__synthesize_thread_map2(struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int perf_event__synthesize_thread_map(struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine, bool mmap_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int perf_event__synthesize_threads(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool mmap_data, unsigned int nr_threads_synthesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, struct evlist *evlist, perf_event__handler_t process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) pid_t perf_event__synthesize_comm(struct perf_tool *tool, union perf_event *event, pid_t pid, perf_event__handler_t process, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int perf_tool__process_synth_event(struct perf_tool *tool, union perf_event *event, struct machine *machine, perf_event__handler_t process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, u64 read_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct target *target, struct perf_thread_map *threads,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) perf_event__handler_t process, bool data_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) unsigned int nr_threads_synthesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int machine__synthesize_threads(struct machine *machine, struct target *target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct perf_thread_map *threads, bool data_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) unsigned int nr_threads_synthesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #ifdef HAVE_AUXTRACE_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, struct perf_tool *tool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct perf_session *session, perf_event__handler_t process);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #else // HAVE_AUXTRACE_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #include <errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct perf_tool *tool __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct perf_session *session __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) perf_event__handler_t process __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #endif // HAVE_AUXTRACE_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #ifdef HAVE_LIBBPF_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int perf_event__synthesize_bpf_events(struct perf_session *session, perf_event__handler_t process,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct machine *machine, struct record_opts *opts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #else // HAVE_LIBBPF_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static inline int perf_event__synthesize_bpf_events(struct perf_session *session __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) perf_event__handler_t process __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct machine *machine __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct record_opts *opts __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #endif // HAVE_LIBBPF_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #endif // __PERF_SYNTHETIC_EVENTS_H