Loading...
1/* 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#include <perf/cpumap.h>
10
11struct auxtrace_record;
12struct dso;
13struct evlist;
14struct evsel;
15struct machine;
16struct perf_counts_values;
17struct perf_cpu_map;
18struct perf_data;
19struct perf_event_attr;
20struct perf_event_mmap_page;
21struct perf_sample;
22struct perf_session;
23struct perf_stat_config;
24struct perf_thread_map;
25struct perf_tool;
26struct record_opts;
27struct target;
28
29union perf_event;
30
31enum perf_record_synth {
32 PERF_SYNTH_TASK = 1 << 0,
33 PERF_SYNTH_MMAP = 1 << 1,
34 PERF_SYNTH_CGROUP = 1 << 2,
35
36 /* last element */
37 PERF_SYNTH_MAX = 1 << 3,
38};
39#define PERF_SYNTH_ALL (PERF_SYNTH_MAX - 1)
40
41int parse_synth_opt(char *str);
42
43typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_event *event,
44 struct perf_sample *sample, struct machine *machine);
45
46int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process);
47int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process);
48int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16 misc, perf_event__handler_t process, struct machine *machine);
49int perf_event__synthesize_cpu_map(struct perf_tool *tool, const struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine);
50int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
51int perf_event__synthesize_event_update_name(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
52int perf_event__synthesize_event_update_scale(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
53int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
54int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlist *evsel_list, perf_event__handler_t process, bool is_pipe);
55int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
56int perf_event__synthesize_features(struct perf_tool *tool, struct perf_session *session, struct evlist *evlist, perf_event__handler_t process);
57int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__handler_t process, struct evlist *evlist, struct machine *machine);
58int __perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__handler_t process, struct evlist *evlist, struct machine *machine, size_t from);
59int perf_event__synthesize_id_sample(__u64 *array, u64 type, const struct perf_sample *sample);
60int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
61int 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);
62int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
63int 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);
64int perf_event__synthesize_cgroups(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
65int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 read_format, const struct perf_sample *sample);
66int perf_event__synthesize_stat_config(struct perf_tool *tool, struct perf_stat_config *config, perf_event__handler_t process, struct machine *machine);
67int perf_event__synthesize_stat_events(struct perf_stat_config *config, struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process, bool attrs);
68int perf_event__synthesize_stat_round(struct perf_tool *tool, u64 time, u64 type, perf_event__handler_t process, struct machine *machine);
69int 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);
70int perf_event__synthesize_thread_map2(struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine);
71int 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);
72int 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);
73int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, struct evlist *evlist, perf_event__handler_t process);
74int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
75pid_t perf_event__synthesize_comm(struct perf_tool *tool, union perf_event *event, pid_t pid, perf_event__handler_t process, struct machine *machine);
76
77int perf_tool__process_synth_event(struct perf_tool *tool, union perf_event *event, struct machine *machine, perf_event__handler_t process);
78
79size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, u64 read_format);
80
81int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
82 struct target *target, struct perf_thread_map *threads,
83 perf_event__handler_t process, bool needs_mmap, bool data_mmap,
84 unsigned int nr_threads_synthesize);
85int machine__synthesize_threads(struct machine *machine, struct target *target,
86 struct perf_thread_map *threads, bool needs_mmap, bool data_mmap,
87 unsigned int nr_threads_synthesize);
88
89#ifdef HAVE_AUXTRACE_SUPPORT
90int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, struct perf_tool *tool,
91 struct perf_session *session, perf_event__handler_t process);
92
93#else // HAVE_AUXTRACE_SUPPORT
94
95#include <errno.h>
96
97static inline int
98perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_unused,
99 struct perf_tool *tool __maybe_unused,
100 struct perf_session *session __maybe_unused,
101 perf_event__handler_t process __maybe_unused)
102{
103 return -EINVAL;
104}
105#endif // HAVE_AUXTRACE_SUPPORT
106
107#ifdef HAVE_LIBBPF_SUPPORT
108int perf_event__synthesize_bpf_events(struct perf_session *session, perf_event__handler_t process,
109 struct machine *machine, struct record_opts *opts);
110#else // HAVE_LIBBPF_SUPPORT
111static inline int perf_event__synthesize_bpf_events(struct perf_session *session __maybe_unused,
112 perf_event__handler_t process __maybe_unused,
113 struct machine *machine __maybe_unused,
114 struct record_opts *opts __maybe_unused)
115{
116 return 0;
117}
118#endif // HAVE_LIBBPF_SUPPORT
119
120int perf_event__synthesize_for_pipe(struct perf_tool *tool,
121 struct perf_session *session,
122 struct perf_data *data,
123 perf_event__handler_t process);
124
125#endif // __PERF_SYNTHETIC_EVENTS_H
1/* 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#include <perf/cpumap.h>
10
11struct auxtrace_record;
12struct build_id;
13struct dso;
14struct evlist;
15struct evsel;
16struct machine;
17struct perf_counts_values;
18struct perf_cpu_map;
19struct perf_data;
20struct perf_event_attr;
21struct perf_event_mmap_page;
22struct perf_sample;
23struct perf_session;
24struct perf_stat_config;
25struct perf_thread_map;
26struct perf_tool;
27struct record_opts;
28struct target;
29
30union perf_event;
31
32enum perf_record_synth {
33 PERF_SYNTH_TASK = 1 << 0,
34 PERF_SYNTH_MMAP = 1 << 1,
35 PERF_SYNTH_CGROUP = 1 << 2,
36
37 /* last element */
38 PERF_SYNTH_MAX = 1 << 3,
39};
40#define PERF_SYNTH_ALL (PERF_SYNTH_MAX - 1)
41
42int parse_synth_opt(char *str);
43
44typedef int (*perf_event__handler_t)(const struct perf_tool *tool, union perf_event *event,
45 struct perf_sample *sample, struct machine *machine);
46
47int perf_event__synthesize_attrs(const struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process);
48int perf_event__synthesize_attr(const struct perf_tool *tool, struct perf_event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process);
49int perf_event__synthesize_build_id(const struct perf_tool *tool,
50 struct perf_sample *sample,
51 struct machine *machine,
52 perf_event__handler_t process,
53 const struct evsel *evsel,
54 __u16 misc,
55 const struct build_id *bid,
56 const char *filename);
57int perf_event__synthesize_mmap2_build_id(const struct perf_tool *tool,
58 struct perf_sample *sample,
59 struct machine *machine,
60 perf_event__handler_t process,
61 const struct evsel *evsel,
62 __u16 misc,
63 __u32 pid, __u32 tid,
64 __u64 start, __u64 len, __u64 pgoff,
65 const struct build_id *bid,
66 __u32 prot, __u32 flags,
67 const char *filename);
68int perf_event__synthesize_cpu_map(const struct perf_tool *tool, const struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine);
69int perf_event__synthesize_event_update_cpus(const struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
70int perf_event__synthesize_event_update_name(const struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
71int perf_event__synthesize_event_update_scale(const struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
72int perf_event__synthesize_event_update_unit(const struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
73int perf_event__synthesize_extra_attr(const struct perf_tool *tool, struct evlist *evsel_list, perf_event__handler_t process, bool is_pipe);
74int perf_event__synthesize_extra_kmaps(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
75int perf_event__synthesize_features(const struct perf_tool *tool, struct perf_session *session, struct evlist *evlist, perf_event__handler_t process);
76int perf_event__synthesize_id_index(const struct perf_tool *tool, perf_event__handler_t process, struct evlist *evlist, struct machine *machine);
77int __perf_event__synthesize_id_index(const struct perf_tool *tool, perf_event__handler_t process, struct evlist *evlist, struct machine *machine, size_t from);
78int perf_event__synthesize_id_sample(__u64 *array, u64 type, const struct perf_sample *sample);
79int perf_event__synthesize_kernel_mmap(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
80int perf_event__synthesize_mmap_events(const 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);
81int perf_event__synthesize_modules(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
82int perf_event__synthesize_namespaces(const struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct machine *machine);
83int perf_event__synthesize_cgroups(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
84int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 read_format, const struct perf_sample *sample);
85int perf_event__synthesize_stat_config(const struct perf_tool *tool, struct perf_stat_config *config, perf_event__handler_t process, struct machine *machine);
86int perf_event__synthesize_stat_events(struct perf_stat_config *config, const struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process, bool attrs);
87int perf_event__synthesize_stat_round(const struct perf_tool *tool, u64 time, u64 type, perf_event__handler_t process, struct machine *machine);
88int perf_event__synthesize_stat(const 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);
89int perf_event__synthesize_thread_map2(const struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine);
90int perf_event__synthesize_thread_map(const struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine, bool needs_mmap, bool mmap_data);
91int perf_event__synthesize_threads(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool needs_mmap, bool mmap_data, unsigned int nr_threads_synthesize);
92int perf_event__synthesize_tracing_data(const struct perf_tool *tool, int fd, struct evlist *evlist, perf_event__handler_t process);
93int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine);
94pid_t perf_event__synthesize_comm(const struct perf_tool *tool, union perf_event *event, pid_t pid, perf_event__handler_t process, struct machine *machine);
95
96int perf_tool__process_synth_event(const struct perf_tool *tool, union perf_event *event, struct machine *machine, perf_event__handler_t process);
97
98size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, u64 read_format);
99
100int __machine__synthesize_threads(struct machine *machine, const struct perf_tool *tool,
101 struct target *target, struct perf_thread_map *threads,
102 perf_event__handler_t process, bool needs_mmap, bool data_mmap,
103 unsigned int nr_threads_synthesize);
104int machine__synthesize_threads(struct machine *machine, struct target *target,
105 struct perf_thread_map *threads, bool needs_mmap, bool data_mmap,
106 unsigned int nr_threads_synthesize);
107
108#ifdef HAVE_AUXTRACE_SUPPORT
109int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, const struct perf_tool *tool,
110 struct perf_session *session, perf_event__handler_t process);
111
112#else // HAVE_AUXTRACE_SUPPORT
113
114#include <errno.h>
115
116static inline int
117perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_unused,
118 const struct perf_tool *tool __maybe_unused,
119 struct perf_session *session __maybe_unused,
120 perf_event__handler_t process __maybe_unused)
121{
122 return -EINVAL;
123}
124#endif // HAVE_AUXTRACE_SUPPORT
125
126#ifdef HAVE_LIBBPF_SUPPORT
127int perf_event__synthesize_bpf_events(struct perf_session *session, perf_event__handler_t process,
128 struct machine *machine, struct record_opts *opts);
129#else // HAVE_LIBBPF_SUPPORT
130static inline int perf_event__synthesize_bpf_events(struct perf_session *session __maybe_unused,
131 perf_event__handler_t process __maybe_unused,
132 struct machine *machine __maybe_unused,
133 struct record_opts *opts __maybe_unused)
134{
135 return 0;
136}
137#endif // HAVE_LIBBPF_SUPPORT
138
139int perf_event__synthesize_for_pipe(const struct perf_tool *tool,
140 struct perf_session *session,
141 struct perf_data *data,
142 perf_event__handler_t process);
143
144#endif // __PERF_SYNTHETIC_EVENTS_H