blob: c931433bacbf4b2c85ed28963ccb1b7bee61a96f [file] [log] [blame]
Arnaldo Carvalho de Meloea49e012019-09-18 11:36:13 -03001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __PERF_SYNTHETIC_EVENTS_H
3#define __PERF_SYNTHETIC_EVENTS_H
4
5#include <stdbool.h>
6#include <sys/types.h> // pid_t
7#include <linux/compiler.h>
8#include <linux/types.h>
9
10struct auxtrace_record;
11struct dso;
12struct evlist;
13struct evsel;
14struct machine;
15struct perf_counts_values;
16struct perf_cpu_map;
Namhyung Kimc3a057d2021-07-19 15:31:52 -070017struct perf_data;
Arnaldo Carvalho de Meloea49e012019-09-18 11:36:13 -030018struct perf_event_attr;
19struct perf_event_mmap_page;
20struct perf_sample;
21struct perf_session;
22struct perf_stat_config;
23struct perf_thread_map;
24struct perf_tool;
25struct record_opts;
26struct target;
27
28union perf_event;
29
Namhyung Kim41b740b2021-08-10 21:46:58 -070030enum perf_record_synth {
31 PERF_SYNTH_TASK = 1 << 0,
32 PERF_SYNTH_MMAP = 1 << 1,
33 PERF_SYNTH_CGROUP = 1 << 2,
34
35 /* last element */
36 PERF_SYNTH_MAX = 1 << 3,
37};
38#define PERF_SYNTH_ALL (PERF_SYNTH_MAX - 1)
39
40int parse_synth_opt(char *str);
41
Arnaldo Carvalho de Meloea49e012019-09-18 11:36:13 -030042typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_event *event,
43 struct perf_sample *sample, struct machine *machine);
44
45int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process);
46int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process);
47int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16 misc, perf_event__handler_t process, struct machine *machine);
48int perf_event__synthesize_cpu_map(struct perf_tool *tool, struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine);
49int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
50int perf_event__synthesize_event_update_name(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
51int perf_event__synthesize_event_update_scale(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
52int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
53int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlist *evsel_list, perf_event__handler_t process, bool is_pipe);
54int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
55int perf_event__synthesize_features(struct perf_tool *tool, struct perf_session *session, struct evlist *evlist, perf_event__handler_t process);
56int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__handler_t process, struct evlist *evlist, struct machine *machine);
57int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
58int 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);
59int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
60int 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);
Namhyung Kimab640692020-03-25 21:45:33 +090061int perf_event__synthesize_cgroups(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
Arnaldo Carvalho de Meloea49e012019-09-18 11:36:13 -030062int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 read_format, const struct perf_sample *sample);
63int perf_event__synthesize_stat_config(struct perf_tool *tool, struct perf_stat_config *config, perf_event__handler_t process, struct machine *machine);
64int perf_event__synthesize_stat_events(struct perf_stat_config *config, struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process, bool attrs);
65int perf_event__synthesize_stat_round(struct perf_tool *tool, u64 time, u64 type, perf_event__handler_t process, struct machine *machine);
66int 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);
67int perf_event__synthesize_thread_map2(struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine);
Namhyung Kim84111b92021-08-10 21:46:57 -070068int 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);
69int 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);
Arnaldo Carvalho de Meloea49e012019-09-18 11:36:13 -030070int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, struct evlist *evlist, perf_event__handler_t process);
71int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
72pid_t perf_event__synthesize_comm(struct perf_tool *tool, union perf_event *event, pid_t pid, perf_event__handler_t process, struct machine *machine);
73
74int perf_tool__process_synth_event(struct perf_tool *tool, union perf_event *event, struct machine *machine, perf_event__handler_t process);
75
76size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, u64 read_format);
77
78int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
79 struct target *target, struct perf_thread_map *threads,
Namhyung Kim84111b92021-08-10 21:46:57 -070080 perf_event__handler_t process, bool needs_mmap, bool data_mmap,
Arnaldo Carvalho de Meloea49e012019-09-18 11:36:13 -030081 unsigned int nr_threads_synthesize);
82int machine__synthesize_threads(struct machine *machine, struct target *target,
Namhyung Kim84111b92021-08-10 21:46:57 -070083 struct perf_thread_map *threads, bool needs_mmap, bool data_mmap,
Arnaldo Carvalho de Meloea49e012019-09-18 11:36:13 -030084 unsigned int nr_threads_synthesize);
85
86#ifdef HAVE_AUXTRACE_SUPPORT
87int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, struct perf_tool *tool,
88 struct perf_session *session, perf_event__handler_t process);
89
90#else // HAVE_AUXTRACE_SUPPORT
91
92#include <errno.h>
93
94static inline int
95perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_unused,
96 struct perf_tool *tool __maybe_unused,
97 struct perf_session *session __maybe_unused,
98 perf_event__handler_t process __maybe_unused)
99{
100 return -EINVAL;
101}
102#endif // HAVE_AUXTRACE_SUPPORT
103
104#ifdef HAVE_LIBBPF_SUPPORT
105int perf_event__synthesize_bpf_events(struct perf_session *session, perf_event__handler_t process,
106 struct machine *machine, struct record_opts *opts);
107#else // HAVE_LIBBPF_SUPPORT
108static inline int perf_event__synthesize_bpf_events(struct perf_session *session __maybe_unused,
109 perf_event__handler_t process __maybe_unused,
110 struct machine *machine __maybe_unused,
111 struct record_opts *opts __maybe_unused)
112{
113 return 0;
114}
115#endif // HAVE_LIBBPF_SUPPORT
116
Namhyung Kimc3a057d2021-07-19 15:31:52 -0700117int perf_event__synthesize_for_pipe(struct perf_tool *tool,
118 struct perf_session *session,
119 struct perf_data *data,
120 perf_event__handler_t process);
121
Arnaldo Carvalho de Meloea49e012019-09-18 11:36:13 -0300122#endif // __PERF_SYNTHETIC_EVENTS_H