Subject: Re: [RFC PATCH bpf-next] xdp: Add tracepoint on XDP program return

From: Toke Høiland-Jørgensen <[email-masked]>
Date: Tue, 17 Dec 2019 09:52:02 +0100

Alexei Starovoitov <[email-masked]> writes:

> On Mon, Dec 16, 2019 at 07:17:59PM +0100, Björn Töpel wrote:
>> On Mon, 16 Dec 2019 at 16:28, Toke Høiland-Jørgensen <[email-masked]> wrote:
>> >
>> > This adds a new tracepoint, xdp_prog_return, which is triggered at every
>> > XDP program return. This was first discussed back in August[0] as a way to
>> > hook XDP into the kernel drop_monitor framework, to have a one-stop place
>> > to find all packet drops in the system.
>> >
>> > Because trace/events/xdp.h includes filter.h, some ifdef guarding is needed
>> > to be able to use the tracepoint from bpf_prog_run_xdp(). If anyone has any
>> > ideas for how to improve on this, please to speak up. Sending this RFC
>> > because of this issue, and to get some feedback from Ido on whether this
>> > tracepoint has enough data for drop_monitor usage.
>> >
>> 
>> I get that it would be useful, but can it be solved with BPF tracing
>> (i.e. tracing BPF with BPF)? It would be neat not adding another
>> tracepoint in the fast-path...
>
> That was my question as well.
> Here is an example from Eelco:
> https://lore.kernel.org/bpf/[email-masked]/
> BPF_TRACE_2("fexit/xdp_prog_simple", trace_on_exit,
>              struct xdp_buff*, xdp, int, ret)
> {
>      bpf_debug("fexit: [ifindex = %u, queue =  %u, ret = %d]\n",
>                xdp->rxq->dev->ifindex, xdp->rxq->queue_index, ret);
>
>      return 0;
> }
> 'ret' is return code from xdp program.
> Such approach is per xdp program, but cheaper when not enabled
> and faster when it's triggering comparing to static tracepoint.
> Anything missing there that you'd like to see?

For userspace, sure, the fentry/fexit stuff is fine. The main use case
for this new tracepoint is to hook into the (in-kernel) drop monitor.
Dunno if that can be convinced to hook into the BPF tracing
infrastructure instead of tracepoints. Ido, WDYT?

-Toke