2 #define TRACE_SYSTEM bpf
4 #if !defined(_TRACE_BPF_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/filter.h>
10 #include <linux/tracepoint.h>
12 #define __PROG_TYPE_MAP(FN) \
26 #define __MAP_TYPE_MAP(FN) \
30 FN(PERF_EVENT_ARRAY) \
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
),
62 __array(u8
, prog_tag
, 8)
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
),
84 DEFINE_EVENT(bpf_prog_event
, bpf_prog_put_rcu
,
86 TP_PROTO(const struct bpf_prog
*prg
),
91 TRACE_EVENT(bpf_prog_load
,
93 TP_PROTO(const struct bpf_prog
*prg
, int ufd
),
98 __array(u8
, prog_tag
, 8)
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
;
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
),
116 TRACE_EVENT(bpf_map_create
,
118 TP_PROTO(const struct bpf_map
*map
, int ufd
),
124 __field(u32
, size_key
)
125 __field(u32
, size_value
)
126 __field(u32
, max_entries
)
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
;
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
),
154 __array(u8
, prog_tag
, 8)
156 __string(path
, pname
->name
)
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
);
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
),
197 __string(path
, pname
->name
)
201 __assign_str(path
, pname
->name
);
202 __entry
->type
= map
->map_type
;
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
),
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
)
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
;
256 TP_printk("map type=%s ufd=%d key=[%s%s] val=[%s%s]",
257 __print_symbolic(__entry
->type
, __MAP_TYPE_SYM_TAB
),
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
,
286 TP_ARGS(map
, ufd
, key
),
290 __field(u32
, key_len
)
291 __dynamic_array(u8
, key
, map
->key_size
)
292 __field(bool, key_trunc
)
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
;
304 TP_printk("map type=%s ufd=%d key=[%s%s]",
305 __print_symbolic(__entry
->type
, __MAP_TYPE_SYM_TAB
),
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
),
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
)
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
;
339 TP_printk("map type=%s ufd=%d key=[%s%s] next=[%s%s]",
340 __print_symbolic(__entry
->type
, __MAP_TYPE_SYM_TAB
),
342 __entry
->key_null
? "NULL" : __print_hex(__get_dynamic_array(key
),
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>