Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / include / trace / events / bpf.h
blob52c8425d144b349988a16366ab69d0366bd0c065
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM bpf
4 #if !defined(_TRACE_BPF_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_BPF_H
7 #include <linux/filter.h>
8 #include <linux/bpf.h>
9 #include <linux/fs.h>
10 #include <linux/tracepoint.h>
12 #define __PROG_TYPE_MAP(FN) \
13 FN(SOCKET_FILTER) \
14 FN(KPROBE) \
15 FN(SCHED_CLS) \
16 FN(SCHED_ACT) \
17 FN(TRACEPOINT) \
18 FN(XDP) \
19 FN(PERF_EVENT) \
20 FN(CGROUP_SKB) \
21 FN(CGROUP_SOCK) \
22 FN(LWT_IN) \
23 FN(LWT_OUT) \
24 FN(LWT_XMIT)
26 #define __MAP_TYPE_MAP(FN) \
27 FN(HASH) \
28 FN(ARRAY) \
29 FN(PROG_ARRAY) \
30 FN(PERF_EVENT_ARRAY) \
31 FN(PERCPU_HASH) \
32 FN(PERCPU_ARRAY) \
33 FN(STACK_TRACE) \
34 FN(CGROUP_ARRAY) \
35 FN(LRU_HASH) \
36 FN(LRU_PERCPU_HASH) \
37 FN(LPM_TRIE)
39 #define __PROG_TYPE_TP_FN(x) \
40 TRACE_DEFINE_ENUM(BPF_PROG_TYPE_##x);
41 #define __PROG_TYPE_SYM_FN(x) \
42 { BPF_PROG_TYPE_##x, #x },
43 #define __PROG_TYPE_SYM_TAB \
44 __PROG_TYPE_MAP(__PROG_TYPE_SYM_FN) { -1, 0 }
45 __PROG_TYPE_MAP(__PROG_TYPE_TP_FN)
47 #define __MAP_TYPE_TP_FN(x) \
48 TRACE_DEFINE_ENUM(BPF_MAP_TYPE_##x);
49 #define __MAP_TYPE_SYM_FN(x) \
50 { BPF_MAP_TYPE_##x, #x },
51 #define __MAP_TYPE_SYM_TAB \
52 __MAP_TYPE_MAP(__MAP_TYPE_SYM_FN) { -1, 0 }
53 __MAP_TYPE_MAP(__MAP_TYPE_TP_FN)
55 DECLARE_EVENT_CLASS(bpf_prog_event,
57 TP_PROTO(const struct bpf_prog *prg),
59 TP_ARGS(prg),
61 TP_STRUCT__entry(
62 __array(u8, prog_tag, 8)
63 __field(u32, type)
66 TP_fast_assign(
67 BUILD_BUG_ON(sizeof(__entry->prog_tag) != sizeof(prg->tag));
68 memcpy(__entry->prog_tag, prg->tag, sizeof(prg->tag));
69 __entry->type = prg->type;
72 TP_printk("prog=%s type=%s",
73 __print_hex_str(__entry->prog_tag, 8),
74 __print_symbolic(__entry->type, __PROG_TYPE_SYM_TAB))
77 DEFINE_EVENT(bpf_prog_event, bpf_prog_get_type,
79 TP_PROTO(const struct bpf_prog *prg),
81 TP_ARGS(prg)
84 DEFINE_EVENT(bpf_prog_event, bpf_prog_put_rcu,
86 TP_PROTO(const struct bpf_prog *prg),
88 TP_ARGS(prg)
91 TRACE_EVENT(bpf_prog_load,
93 TP_PROTO(const struct bpf_prog *prg, int ufd),
95 TP_ARGS(prg, ufd),
97 TP_STRUCT__entry(
98 __array(u8, prog_tag, 8)
99 __field(u32, type)
100 __field(int, ufd)
103 TP_fast_assign(
104 BUILD_BUG_ON(sizeof(__entry->prog_tag) != sizeof(prg->tag));
105 memcpy(__entry->prog_tag, prg->tag, sizeof(prg->tag));
106 __entry->type = prg->type;
107 __entry->ufd = ufd;
110 TP_printk("prog=%s type=%s ufd=%d",
111 __print_hex_str(__entry->prog_tag, 8),
112 __print_symbolic(__entry->type, __PROG_TYPE_SYM_TAB),
113 __entry->ufd)
116 TRACE_EVENT(bpf_map_create,
118 TP_PROTO(const struct bpf_map *map, int ufd),
120 TP_ARGS(map, ufd),
122 TP_STRUCT__entry(
123 __field(u32, type)
124 __field(u32, size_key)
125 __field(u32, size_value)
126 __field(u32, max_entries)
127 __field(u32, flags)
128 __field(int, ufd)
131 TP_fast_assign(
132 __entry->type = map->map_type;
133 __entry->size_key = map->key_size;
134 __entry->size_value = map->value_size;
135 __entry->max_entries = map->max_entries;
136 __entry->flags = map->map_flags;
137 __entry->ufd = ufd;
140 TP_printk("map type=%s ufd=%d key=%u val=%u max=%u flags=%x",
141 __print_symbolic(__entry->type, __MAP_TYPE_SYM_TAB),
142 __entry->ufd, __entry->size_key, __entry->size_value,
143 __entry->max_entries, __entry->flags)
146 DECLARE_EVENT_CLASS(bpf_obj_prog,
148 TP_PROTO(const struct bpf_prog *prg, int ufd,
149 const struct filename *pname),
151 TP_ARGS(prg, ufd, pname),
153 TP_STRUCT__entry(
154 __array(u8, prog_tag, 8)
155 __field(int, ufd)
156 __string(path, pname->name)
159 TP_fast_assign(
160 BUILD_BUG_ON(sizeof(__entry->prog_tag) != sizeof(prg->tag));
161 memcpy(__entry->prog_tag, prg->tag, sizeof(prg->tag));
162 __assign_str(path, pname->name);
163 __entry->ufd = ufd;
166 TP_printk("prog=%s path=%s ufd=%d",
167 __print_hex_str(__entry->prog_tag, 8),
168 __get_str(path), __entry->ufd)
171 DEFINE_EVENT(bpf_obj_prog, bpf_obj_pin_prog,
173 TP_PROTO(const struct bpf_prog *prg, int ufd,
174 const struct filename *pname),
176 TP_ARGS(prg, ufd, pname)
179 DEFINE_EVENT(bpf_obj_prog, bpf_obj_get_prog,
181 TP_PROTO(const struct bpf_prog *prg, int ufd,
182 const struct filename *pname),
184 TP_ARGS(prg, ufd, pname)
187 DECLARE_EVENT_CLASS(bpf_obj_map,
189 TP_PROTO(const struct bpf_map *map, int ufd,
190 const struct filename *pname),
192 TP_ARGS(map, ufd, pname),
194 TP_STRUCT__entry(
195 __field(u32, type)
196 __field(int, ufd)
197 __string(path, pname->name)
200 TP_fast_assign(
201 __assign_str(path, pname->name);
202 __entry->type = map->map_type;
203 __entry->ufd = ufd;
206 TP_printk("map type=%s ufd=%d path=%s",
207 __print_symbolic(__entry->type, __MAP_TYPE_SYM_TAB),
208 __entry->ufd, __get_str(path))
211 DEFINE_EVENT(bpf_obj_map, bpf_obj_pin_map,
213 TP_PROTO(const struct bpf_map *map, int ufd,
214 const struct filename *pname),
216 TP_ARGS(map, ufd, pname)
219 DEFINE_EVENT(bpf_obj_map, bpf_obj_get_map,
221 TP_PROTO(const struct bpf_map *map, int ufd,
222 const struct filename *pname),
224 TP_ARGS(map, ufd, pname)
227 DECLARE_EVENT_CLASS(bpf_map_keyval,
229 TP_PROTO(const struct bpf_map *map, int ufd,
230 const void *key, const void *val),
232 TP_ARGS(map, ufd, key, val),
234 TP_STRUCT__entry(
235 __field(u32, type)
236 __field(u32, key_len)
237 __dynamic_array(u8, key, map->key_size)
238 __field(bool, key_trunc)
239 __field(u32, val_len)
240 __dynamic_array(u8, val, map->value_size)
241 __field(bool, val_trunc)
242 __field(int, ufd)
245 TP_fast_assign(
246 memcpy(__get_dynamic_array(key), key, map->key_size);
247 memcpy(__get_dynamic_array(val), val, map->value_size);
248 __entry->type = map->map_type;
249 __entry->key_len = min(map->key_size, 16U);
250 __entry->key_trunc = map->key_size != __entry->key_len;
251 __entry->val_len = min(map->value_size, 16U);
252 __entry->val_trunc = map->value_size != __entry->val_len;
253 __entry->ufd = ufd;
256 TP_printk("map type=%s ufd=%d key=[%s%s] val=[%s%s]",
257 __print_symbolic(__entry->type, __MAP_TYPE_SYM_TAB),
258 __entry->ufd,
259 __print_hex(__get_dynamic_array(key), __entry->key_len),
260 __entry->key_trunc ? " ..." : "",
261 __print_hex(__get_dynamic_array(val), __entry->val_len),
262 __entry->val_trunc ? " ..." : "")
265 DEFINE_EVENT(bpf_map_keyval, bpf_map_lookup_elem,
267 TP_PROTO(const struct bpf_map *map, int ufd,
268 const void *key, const void *val),
270 TP_ARGS(map, ufd, key, val)
273 DEFINE_EVENT(bpf_map_keyval, bpf_map_update_elem,
275 TP_PROTO(const struct bpf_map *map, int ufd,
276 const void *key, const void *val),
278 TP_ARGS(map, ufd, key, val)
281 TRACE_EVENT(bpf_map_delete_elem,
283 TP_PROTO(const struct bpf_map *map, int ufd,
284 const void *key),
286 TP_ARGS(map, ufd, key),
288 TP_STRUCT__entry(
289 __field(u32, type)
290 __field(u32, key_len)
291 __dynamic_array(u8, key, map->key_size)
292 __field(bool, key_trunc)
293 __field(int, ufd)
296 TP_fast_assign(
297 memcpy(__get_dynamic_array(key), key, map->key_size);
298 __entry->type = map->map_type;
299 __entry->key_len = min(map->key_size, 16U);
300 __entry->key_trunc = map->key_size != __entry->key_len;
301 __entry->ufd = ufd;
304 TP_printk("map type=%s ufd=%d key=[%s%s]",
305 __print_symbolic(__entry->type, __MAP_TYPE_SYM_TAB),
306 __entry->ufd,
307 __print_hex(__get_dynamic_array(key), __entry->key_len),
308 __entry->key_trunc ? " ..." : "")
311 TRACE_EVENT(bpf_map_next_key,
313 TP_PROTO(const struct bpf_map *map, int ufd,
314 const void *key, const void *key_next),
316 TP_ARGS(map, ufd, key, key_next),
318 TP_STRUCT__entry(
319 __field(u32, type)
320 __field(u32, key_len)
321 __dynamic_array(u8, key, map->key_size)
322 __dynamic_array(u8, nxt, map->key_size)
323 __field(bool, key_trunc)
324 __field(bool, key_null)
325 __field(int, ufd)
328 TP_fast_assign(
329 if (key)
330 memcpy(__get_dynamic_array(key), key, map->key_size);
331 __entry->key_null = !key;
332 memcpy(__get_dynamic_array(nxt), key_next, map->key_size);
333 __entry->type = map->map_type;
334 __entry->key_len = min(map->key_size, 16U);
335 __entry->key_trunc = map->key_size != __entry->key_len;
336 __entry->ufd = ufd;
339 TP_printk("map type=%s ufd=%d key=[%s%s] next=[%s%s]",
340 __print_symbolic(__entry->type, __MAP_TYPE_SYM_TAB),
341 __entry->ufd,
342 __entry->key_null ? "NULL" : __print_hex(__get_dynamic_array(key),
343 __entry->key_len),
344 __entry->key_trunc && !__entry->key_null ? " ..." : "",
345 __print_hex(__get_dynamic_array(nxt), __entry->key_len),
346 __entry->key_trunc ? " ..." : "")
349 #endif /* _TRACE_BPF_H */
351 #include <trace/define_trace.h>