0001
0002 #ifndef __PERF_SYNTHETIC_EVENTS_H
0003 #define __PERF_SYNTHETIC_EVENTS_H
0004
0005 #include <stdbool.h>
0006 #include <sys/types.h> // pid_t
0007 #include <linux/compiler.h>
0008 #include <linux/types.h>
0009 #include <perf/cpumap.h>
0010
0011 struct auxtrace_record;
0012 struct dso;
0013 struct evlist;
0014 struct evsel;
0015 struct machine;
0016 struct perf_counts_values;
0017 struct perf_cpu_map;
0018 struct perf_data;
0019 struct perf_event_attr;
0020 struct perf_event_mmap_page;
0021 struct perf_sample;
0022 struct perf_session;
0023 struct perf_stat_config;
0024 struct perf_thread_map;
0025 struct perf_tool;
0026 struct record_opts;
0027 struct target;
0028
0029 union perf_event;
0030
0031 enum perf_record_synth {
0032 PERF_SYNTH_TASK = 1 << 0,
0033 PERF_SYNTH_MMAP = 1 << 1,
0034 PERF_SYNTH_CGROUP = 1 << 2,
0035
0036
0037 PERF_SYNTH_MAX = 1 << 3,
0038 };
0039 #define PERF_SYNTH_ALL (PERF_SYNTH_MAX - 1)
0040
0041 int parse_synth_opt(char *str);
0042
0043 typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_event *event,
0044 struct perf_sample *sample, struct machine *machine);
0045
0046 int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process);
0047 int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process);
0048 int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16 misc, perf_event__handler_t process, struct machine *machine);
0049 int perf_event__synthesize_cpu_map(struct perf_tool *tool, const struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine);
0050 int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
0051 int perf_event__synthesize_event_update_name(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
0052 int perf_event__synthesize_event_update_scale(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
0053 int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
0054 int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlist *evsel_list, perf_event__handler_t process, bool is_pipe);
0055 int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
0056 int perf_event__synthesize_features(struct perf_tool *tool, struct perf_session *session, struct evlist *evlist, perf_event__handler_t process);
0057 int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__handler_t process, struct evlist *evlist, struct machine *machine);
0058 int __perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__handler_t process, struct evlist *evlist, struct machine *machine, size_t from);
0059 int perf_event__synthesize_id_sample(__u64 *array, u64 type, const struct perf_sample *sample);
0060 int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
0061 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);
0062 int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
0063 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);
0064 int perf_event__synthesize_cgroups(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
0065 int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 read_format, const struct perf_sample *sample);
0066 int perf_event__synthesize_stat_config(struct perf_tool *tool, struct perf_stat_config *config, perf_event__handler_t process, struct machine *machine);
0067 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);
0068 int perf_event__synthesize_stat_round(struct perf_tool *tool, u64 time, u64 type, perf_event__handler_t process, struct machine *machine);
0069 int perf_event__synthesize_stat(struct perf_tool *tool, struct perf_cpu cpu, u32 thread, u64 id, struct perf_counts_values *count, perf_event__handler_t process, struct machine *machine);
0070 int perf_event__synthesize_thread_map2(struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine);
0071 int perf_event__synthesize_thread_map(struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine, bool needs_mmap, bool mmap_data);
0072 int perf_event__synthesize_threads(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool needs_mmap, bool mmap_data, unsigned int nr_threads_synthesize);
0073 int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, struct evlist *evlist, perf_event__handler_t process);
0074 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);
0075 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);
0076
0077 int perf_tool__process_synth_event(struct perf_tool *tool, union perf_event *event, struct machine *machine, perf_event__handler_t process);
0078
0079 size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, u64 read_format);
0080
0081 int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
0082 struct target *target, struct perf_thread_map *threads,
0083 perf_event__handler_t process, bool needs_mmap, bool data_mmap,
0084 unsigned int nr_threads_synthesize);
0085 int machine__synthesize_threads(struct machine *machine, struct target *target,
0086 struct perf_thread_map *threads, bool needs_mmap, bool data_mmap,
0087 unsigned int nr_threads_synthesize);
0088
0089 #ifdef HAVE_AUXTRACE_SUPPORT
0090 int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, struct perf_tool *tool,
0091 struct perf_session *session, perf_event__handler_t process);
0092
0093 #else
0094
0095 #include <errno.h>
0096
0097 static inline int
0098 perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_unused,
0099 struct perf_tool *tool __maybe_unused,
0100 struct perf_session *session __maybe_unused,
0101 perf_event__handler_t process __maybe_unused)
0102 {
0103 return -EINVAL;
0104 }
0105 #endif
0106
0107 #ifdef HAVE_LIBBPF_SUPPORT
0108 int perf_event__synthesize_bpf_events(struct perf_session *session, perf_event__handler_t process,
0109 struct machine *machine, struct record_opts *opts);
0110 #else
0111 static inline int perf_event__synthesize_bpf_events(struct perf_session *session __maybe_unused,
0112 perf_event__handler_t process __maybe_unused,
0113 struct machine *machine __maybe_unused,
0114 struct record_opts *opts __maybe_unused)
0115 {
0116 return 0;
0117 }
0118 #endif
0119
0120 int perf_event__synthesize_for_pipe(struct perf_tool *tool,
0121 struct perf_session *session,
0122 struct perf_data *data,
0123 perf_event__handler_t process);
0124
0125 #endif