Thread (18 messages) 18 messages, 2 authors, 2021-05-30

Re: [PATCH RFC bpf-next 15/15] samples: bpf: convert xdp_samples to use raw_tracepoints

flat view

From: Andrii Nakryiko <hidden>
Date: 2021-05-30 03:07:56
Also in: bpf

On Fri, May 28, 2021 at 4:54 PM Kumar Kartikeya Dwivedi
[off-list ref] wrote:
These are faster, and hence speeds up cases where user passes --stats to
enable success case redirect accounting. We can extend this to all other
tracepoints as well, so make that part of this change.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 samples/bpf/xdp_sample_kern.h | 145 +++++++++++-----------------------
 samples/bpf/xdp_sample_user.c |   2 +-
 2 files changed, 45 insertions(+), 102 deletions(-)
[...]
quoted hunk ↗ jump to hunk

-/* Tracepoint format: /sys/kernel/debug/tracing/events/xdp/xdp_exception/format
- * Code in:                kernel/include/trace/events/xdp.h
- */
-struct xdp_exception_ctx {
-       u64 __pad;      // First 8 bytes are not accessible by bpf code
-       int prog_id;    //      offset:8;  size:4; signed:1;
-       u32 act;        //      offset:12; size:4; signed:0;
-       int ifindex;    //      offset:16; size:4; signed:1;
-};
-
-SEC("tracepoint/xdp/xdp_exception")
-int trace_xdp_exception(struct xdp_exception_ctx *ctx)
+SEC("raw_tracepoint/xdp_exception")
+int trace_xdp_exception(struct bpf_raw_tracepoint_args *ctx)
 {
check out use of BPF_PROG macro for raw_tracepoint and fentry/fexit
programs, it looks nicer, IMO.
quoted hunk ↗ jump to hunk
+       u32 key = ctx->args[2];
        struct datarec *rec;
-       u32 key = ctx->act;

        if (key > XDP_REDIRECT)
                key = XDP_UNKNOWN;
[...]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help