[bpf-next PATCH 2/3] bpf: add id to prog tracepoint

Sebastiano Miano
2018-04-18T15:58:27Z

This patch adds the prog id to the bpf tracepoints
that can be used when monitoring or inspecting prog
related functions.

Signed-off-by: Sebastiano Miano <sebastiano.miano@polito.it>
Suggested-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
include/trace/events/bpf.h | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/trace/events/bpf.h b/include/trace/events/bpf.h
index d7c9726..4ec19c5 100644
--- a/include/trace/events/bpf.h
+++ b/include/trace/events/bpf.h
@@ -65,16 +65,19 @@ DECLARE_EVENT_CLASS(bpf_prog_event,
TP_STRUCT__entry(
__array(u8, prog_tag, 8)
__field(u32, type)
+ __field(u32, id)
),

TP_fast_assign(
BUILD_BUG_ON(sizeof(__entry->prog_tag) != sizeof(prg->tag));
memcpy(__entry->prog_tag, prg->tag, sizeof(prg->tag));
__entry->type = prg->type;
+ __entry->id = prg->aux->id;
),

- TP_printk("prog=%s type=%s",
+ TP_printk("prog=%s id=%u type=%s",
__print_hex_str(__entry->prog_tag, 8),
+ __entry->id,
__print_symbolic(__entry->type, __PROG_TYPE_SYM_TAB))
);

@@ -102,6 +105,7 @@ TRACE_EVENT(bpf_prog_load,
__array(u8, prog_tag, 8)
__field(u32, type)
__field(int, ufd)
+ __field(u32, id)
),

TP_fast_assign(
@@ -109,10 +113,12 @@ TRACE_EVENT(bpf_prog_load,
memcpy(__entry->prog_tag, prg->tag, sizeof(prg->tag));
__entry->type = prg->type;
__entry->ufd = ufd;
+ __entry->id = prg->aux->id;
),

- TP_printk("prog=%s type=%s ufd=%d",
+ TP_printk("prog=%s id=%u type=%s ufd=%d",
__print_hex_str(__entry->prog_tag, 8),
+ __entry->id,
__print_symbolic(__entry->type, __PROG_TYPE_SYM_TAB),
__entry->ufd)
);
@@ -161,6 +167,7 @@ DECLARE_EVENT_CLASS(bpf_obj_prog,
__array(u8, prog_tag, 8)
__field(int, ufd)
__string(path, pname->name)
+ __field(u32, id)
),

TP_fast_assign(
@@ -168,10 +175,12 @@ DECLARE_EVENT_CLASS(bpf_obj_prog,
memcpy(__entry->prog_tag, prg->tag, sizeof(prg->tag));
__assign_str(path, pname->name);
__entry->ufd = ufd;
+ __entry->id = prg->aux->id;
),

- TP_printk("prog=%s path=%s ufd=%d",
+ TP_printk("prog=%s id=%u path=%s ufd=%d",
__print_hex_str(__entry->prog_tag, 8),
+ __entry->id,
__get_str(path), __entry->ufd)
);