Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / include / trace / events / bpf.h
blob150185647e6b20246f0bde0743e23f1b449cffeb
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM bpf
5 #if !defined(_TRACE_BPF_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_BPF_H
8 /* These are only used within the BPF_SYSCALL code */
9 #ifdef CONFIG_BPF_SYSCALL
11 #include <linux/filter.h>
12 #include <linux/bpf.h>
13 #include <linux/fs.h>
14 #include <linux/tracepoint.h>
16 #define __PROG_TYPE_MAP(FN) \
17 FN(SOCKET_FILTER) \
18 FN(KPROBE) \
19 FN(SCHED_CLS) \
20 FN(SCHED_ACT) \
21 FN(TRACEPOINT) \
22 FN(XDP) \
23 FN(PERF_EVENT) \
24 FN(CGROUP_SKB) \
25 FN(CGROUP_SOCK) \
26 FN(LWT_IN) \
27 FN(LWT_OUT) \
28 FN(LWT_XMIT)
30 #define __MAP_TYPE_MAP(FN) \
31 FN(HASH) \
32 FN(ARRAY) \
33 FN(PROG_ARRAY) \
34 FN(PERF_EVENT_ARRAY) \
35 FN(PERCPU_HASH) \
36 FN(PERCPU_ARRAY) \
37 FN(STACK_TRACE) \
38 FN(CGROUP_ARRAY) \
39 FN(LRU_HASH) \
40 FN(LRU_PERCPU_HASH) \
41 FN(LPM_TRIE)
43 #define __PROG_TYPE_TP_FN(x) \
44 TRACE_DEFINE_ENUM(BPF_PROG_TYPE_##x);
45 #define __PROG_TYPE_SYM_FN(x) \
46 { BPF_PROG_TYPE_##x, #x },
47 #define __PROG_TYPE_SYM_TAB \
48 __PROG_TYPE_MAP(__PROG_TYPE_SYM_FN) { -1, 0 }
49 __PROG_TYPE_MAP(__PROG_TYPE_TP_FN)
51 #define __MAP_TYPE_TP_FN(x) \
52 TRACE_DEFINE_ENUM(BPF_MAP_TYPE_##x);
53 #define __MAP_TYPE_SYM_FN(x) \
54 { BPF_MAP_TYPE_##x, #x },
55 #define __MAP_TYPE_SYM_TAB \
56 __MAP_TYPE_MAP(__MAP_TYPE_SYM_FN) { -1, 0 }
57 __MAP_TYPE_MAP(__MAP_TYPE_TP_FN)
59 DECLARE_EVENT_CLASS(bpf_prog_event,
61 TP_PROTO(const struct bpf_prog *prg),
63 TP_ARGS(prg),
65 TP_STRUCT__entry(
66 __array(u8, prog_tag, 8)
67 __field(u32, type)
70 TP_fast_assign(
71 BUILD_BUG_ON(sizeof(__entry->prog_tag) != sizeof(prg->tag));
72 memcpy(__entry->prog_tag, prg->tag, sizeof(prg->tag));
73 __entry->type = prg->type;
76 TP_printk("prog=%s type=%s",
77 __print_hex_str(__entry->prog_tag, 8),
78 __print_symbolic(__entry->type, __PROG_TYPE_SYM_TAB))
81 DEFINE_EVENT(bpf_prog_event, bpf_prog_get_type,
83 TP_PROTO(const struct bpf_prog *prg),
85 TP_ARGS(prg)
88 DEFINE_EVENT(bpf_prog_event, bpf_prog_put_rcu,
90 TP_PROTO(const struct bpf_prog *prg),
92 TP_ARGS(prg)
95 TRACE_EVENT(bpf_prog_load,
97 TP_PROTO(const struct bpf_prog *prg, int ufd),
99 TP_ARGS(prg, ufd),
101 TP_STRUCT__entry(
102 __array(u8, prog_tag, 8)
103 __field(u32, type)
104 __field(int, ufd)
107 TP_fast_assign(
108 BUILD_BUG_ON(sizeof(__entry->prog_tag) != sizeof(prg->tag));
109 memcpy(__entry->prog_tag, prg->tag, sizeof(prg->tag));
110 __entry->type = prg->type;
111 __entry->ufd = ufd;
114 TP_printk("prog=%s type=%s ufd=%d",
115 __print_hex_str(__entry->prog_tag, 8),
116 __print_symbolic(__entry->type, __PROG_TYPE_SYM_TAB),
117 __entry->ufd)
120 TRACE_EVENT(bpf_map_create,
122 TP_PROTO(const struct bpf_map *map, int ufd),
124 TP_ARGS(map, ufd),
126 TP_STRUCT__entry(
127 __field(u32, type)
128 __field(u32, size_key)
129 __field(u32, size_value)
130 __field(u32, max_entries)
131 __field(u32, flags)
132 __field(int, ufd)
135 TP_fast_assign(
136 __entry->type = map->map_type;
137 __entry->size_key = map->key_size;
138 __entry->size_value = map->value_size;
139 __entry->max_entries = map->max_entries;
140 __entry->flags = map->map_flags;
141 __entry->ufd = ufd;
144 TP_printk("map type=%s ufd=%d key=%u val=%u max=%u flags=%x",
145 __print_symbolic(__entry->type, __MAP_TYPE_SYM_TAB),
146 __entry->ufd, __entry->size_key, __entry->size_value,
147 __entry->max_entries, __entry->flags)
150 DECLARE_EVENT_CLASS(bpf_obj_prog,
152 TP_PROTO(const struct bpf_prog *prg, int ufd,
153 const struct filename *pname),
155 TP_ARGS(prg, ufd, pname),
157 TP_STRUCT__entry(
158 __array(u8, prog_tag, 8)
159 __field(int, ufd)
160 __string(path, pname->name)
163 TP_fast_assign(
164 BUILD_BUG_ON(sizeof(__entry->prog_tag) != sizeof(prg->tag));
165 memcpy(__entry->prog_tag, prg->tag, sizeof(prg->tag));
166 __assign_str(path, pname->name);
167 __entry->ufd = ufd;
170 TP_printk("prog=%s path=%s ufd=%d",
171 __print_hex_str(__entry->prog_tag, 8),
172 __get_str(path), __entry->ufd)
175 DEFINE_EVENT(bpf_obj_prog, bpf_obj_pin_prog,
177 TP_PROTO(const struct bpf_prog *prg, int ufd,
178 const struct filename *pname),
180 TP_ARGS(prg, ufd, pname)
183 DEFINE_EVENT(bpf_obj_prog, bpf_obj_get_prog,
185 TP_PROTO(const struct bpf_prog *prg, int ufd,
186 const struct filename *pname),
188 TP_ARGS(prg, ufd, pname)
191 DECLARE_EVENT_CLASS(bpf_obj_map,
193 TP_PROTO(const struct bpf_map *map, int ufd,
194 const struct filename *pname),
196 TP_ARGS(map, ufd, pname),
198 TP_STRUCT__entry(
199 __field(u32, type)
200 __field(int, ufd)
201 __string(path, pname->name)
204 TP_fast_assign(
205 __assign_str(path, pname->name);
206 __entry->type = map->map_type;
207 __entry->ufd = ufd;
210 TP_printk("map type=%s ufd=%d path=%s",
211 __print_symbolic(__entry->type, __MAP_TYPE_SYM_TAB),
212 __entry->ufd, __get_str(path))
215 DEFINE_EVENT(bpf_obj_map, bpf_obj_pin_map,
217 TP_PROTO(const struct bpf_map *map, int ufd,
218 const struct filename *pname),
220 TP_ARGS(map, ufd, pname)
223 DEFINE_EVENT(bpf_obj_map, bpf_obj_get_map,
225 TP_PROTO(const struct bpf_map *map, int ufd,
226 const struct filename *pname),
228 TP_ARGS(map, ufd, pname)
231 DECLARE_EVENT_CLASS(bpf_map_keyval,
233 TP_PROTO(const struct bpf_map *map, int ufd,
234 const void *key, const void *val),
236 TP_ARGS(map, ufd, key, val),
238 TP_STRUCT__entry(
239 __field(u32, type)
240 __field(u32, key_len)
241 __dynamic_array(u8, key, map->key_size)
242 __field(bool, key_trunc)
243 __field(u32, val_len)
244 __dynamic_array(u8, val, map->value_size)
245 __field(bool, val_trunc)
246 __field(int, ufd)
249 TP_fast_assign(
250 memcpy(__get_dynamic_array(key), key, map->key_size);
251 memcpy(__get_dynamic_array(val), val, map->value_size);
252 __entry->type = map->map_type;
253 __entry->key_len = min(map->key_size, 16U);
254 __entry->key_trunc = map->key_size != __entry->key_len;
255 __entry->val_len = min(map->value_size, 16U);
256 __entry->val_trunc = map->value_size != __entry->val_len;
257 __entry->ufd = ufd;
260 TP_printk("map type=%s ufd=%d key=[%s%s] val=[%s%s]",
261 __print_symbolic(__entry->type, __MAP_TYPE_SYM_TAB),
262 __entry->ufd,
263 __print_hex(__get_dynamic_array(key), __entry->key_len),
264 __entry->key_trunc ? " ..." : "",
265 __print_hex(__get_dynamic_array(val), __entry->val_len),
266 __entry->val_trunc ? " ..." : "")
269 DEFINE_EVENT(bpf_map_keyval, bpf_map_lookup_elem,
271 TP_PROTO(const struct bpf_map *map, int ufd,
272 const void *key, const void *val),
274 TP_ARGS(map, ufd, key, val)
277 DEFINE_EVENT(bpf_map_keyval, bpf_map_update_elem,
279 TP_PROTO(const struct bpf_map *map, int ufd,
280 const void *key, const void *val),
282 TP_ARGS(map, ufd, key, val)
285 TRACE_EVENT(bpf_map_delete_elem,
287 TP_PROTO(const struct bpf_map *map, int ufd,
288 const void *key),
290 TP_ARGS(map, ufd, key),
292 TP_STRUCT__entry(
293 __field(u32, type)
294 __field(u32, key_len)
295 __dynamic_array(u8, key, map->key_size)
296 __field(bool, key_trunc)
297 __field(int, ufd)
300 TP_fast_assign(
301 memcpy(__get_dynamic_array(key), key, map->key_size);
302 __entry->type = map->map_type;
303 __entry->key_len = min(map->key_size, 16U);
304 __entry->key_trunc = map->key_size != __entry->key_len;
305 __entry->ufd = ufd;
308 TP_printk("map type=%s ufd=%d key=[%s%s]",
309 __print_symbolic(__entry->type, __MAP_TYPE_SYM_TAB),
310 __entry->ufd,
311 __print_hex(__get_dynamic_array(key), __entry->key_len),
312 __entry->key_trunc ? " ..." : "")
315 TRACE_EVENT(bpf_map_next_key,
317 TP_PROTO(const struct bpf_map *map, int ufd,
318 const void *key, const void *key_next),
320 TP_ARGS(map, ufd, key, key_next),
322 TP_STRUCT__entry(
323 __field(u32, type)
324 __field(u32, key_len)
325 __dynamic_array(u8, key, map->key_size)
326 __dynamic_array(u8, nxt, map->key_size)
327 __field(bool, key_trunc)
328 __field(bool, key_null)
329 __field(int, ufd)
332 TP_fast_assign(
333 if (key)
334 memcpy(__get_dynamic_array(key), key, map->key_size);
335 __entry->key_null = !key;
336 memcpy(__get_dynamic_array(nxt), key_next, map->key_size);
337 __entry->type = map->map_type;
338 __entry->key_len = min(map->key_size, 16U);
339 __entry->key_trunc = map->key_size != __entry->key_len;
340 __entry->ufd = ufd;
343 TP_printk("map type=%s ufd=%d key=[%s%s] next=[%s%s]",
344 __print_symbolic(__entry->type, __MAP_TYPE_SYM_TAB),
345 __entry->ufd,
346 __entry->key_null ? "NULL" : __print_hex(__get_dynamic_array(key),
347 __entry->key_len),
348 __entry->key_trunc && !__entry->key_null ? " ..." : "",
349 __print_hex(__get_dynamic_array(nxt), __entry->key_len),
350 __entry->key_trunc ? " ..." : "")
352 #endif /* CONFIG_BPF_SYSCALL */
353 #endif /* _TRACE_BPF_H */
355 #include <trace/define_trace.h>