Björn Töpel <bjorn.topel@xxxxxxxxx> writes: > On Thu, 7 May 2020 at 20:08, John Fastabend <john.fastabend@xxxxxxxxx> wrote: >> > [] >> >> I'm wondering if we can teach the verifier to recognize tail calls, >> >> int xdp_prog1(struct xdp_md *ctx) >> { >> return xdp_do_redirect(ctx, &xsks_map, 0); >> } >> >> This would be useful for normal calls as well. I guess the question here >> is would a tail call be sufficient for above case or do you need the >> 'return XDP_PASS' at the end? If so maybe we could fold it into the >> helper somehow. >> > > No, that was just for handling the "failed call", bpf_tail_call() style. > >> I think it would also address Toke's concerns, no new action so >> bpf developers can just develope like normal but "smart" developers >> will try do calls as tail calls. Not sure it can be done without >> driver changes though. >> > > Take me though this. So, the new xdp_do_redirect() would return > XDP_REDIRECT? If the call is a tail call, we can "consume" (perform > the REDIRECT action) in the helper, set a "we're done/tail call > performed" flag in bpf_redirect_info and the xdp_do_redirect() checks > this flag and returns directly. If the call is *not* a tail call, the > regular REDIRECT path is performed. Am I following that correctly? So > we would be able to detect if the optimization has been performed, so > the "consume" semantics can be done. Yeah, that was my understanding. And what I meant with the 'new flag' bit was that you could prototype this by just adding a new flag to bpf_redirect_map() which would trigger this consume behaviour. That would allow you to get performance numbers without waiting for the verifier to learn about tail calls... :) -Toke