From: Daniel Borkmann <daniel@iogearbox.net>
To: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
netdev@vger.kernel.org, Michael Ellerman <mpe@ellerman.id.au>
Cc: Alexei Starovoitov <ast@fb.com>,
"David S. Miller" <davem@davemloft.net>,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Subject: Re: [PATCH 2/3] bpf powerpc: implement support for tail calls
Date: Sat, 24 Sep 2016 00:33:54 +0200 [thread overview]
Message-ID: <57E5ADD2.7090308@iogearbox.net> (raw)
In-Reply-To: <c7c16b999694b2851705d79da939988e521bda3a.1474661927.git.naveen.n.rao@linux.vnet.ibm.com>
On 09/23/2016 10:35 PM, Naveen N. Rao wrote:
> Tail calls allow JIT'ed eBPF programs to call into other JIT'ed eBPF
> programs. This can be achieved either by:
> (1) retaining the stack setup by the first eBPF program and having all
> subsequent eBPF programs re-using it, or,
> (2) by unwinding/tearing down the stack and having each eBPF program
> deal with its own stack as it sees fit.
>
> To ensure that this does not create loops, there is a limit to how many
> tail calls can be done (currently 32). This requires the JIT'ed code to
> maintain a count of the number of tail calls done so far.
>
> Approach (1) is simple, but requires every eBPF program to have (almost)
> the same prologue/epilogue, regardless of whether they need it. This is
> inefficient for small eBPF programs which may not sometimes need a
> prologue at all. As such, to minimize impact of tail call
> implementation, we use approach (2) here which needs each eBPF program
> in the chain to use its own prologue/epilogue. This is not ideal when
> many tail calls are involved and when all the eBPF programs in the chain
> have similar prologue/epilogue. However, the impact is restricted to
> programs that do tail calls. Individual eBPF programs are not affected.
>
> We maintain the tail call count in a fixed location on the stack and
> updated tail call count values are passed in through this. The very
> first eBPF program in a chain sets this up to 0 (the first 2
> instructions). Subsequent tail calls skip the first two eBPF JIT
> instructions to maintain the count. For programs that don't do tail
> calls themselves, the first two instructions are NOPs.
>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Thanks for adding support, Naveen, that's really great! I think 2) seems
fine as well in this context as prologue size can vary quite a bit here,
and depending on program types likelihood of tail call usage as well (but
I wouldn't expect deep nesting). Thanks a lot!
next prev parent reply other threads:[~2016-09-23 22:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 20:35 [PATCH 1/3] bpf powerpc: introduce accessors for using the tmp local stack space Naveen N. Rao
2016-09-23 20:35 ` [PATCH 2/3] bpf powerpc: implement support for tail calls Naveen N. Rao
2016-09-23 22:33 ` Daniel Borkmann [this message]
2016-09-24 7:30 ` Alexei Starovoitov
2016-09-26 8:56 ` Naveen N. Rao
2016-09-26 9:00 ` Daniel Borkmann
2016-09-26 9:09 ` Naveen N. Rao
2016-09-23 20:35 ` [PATCH 3/3] bpf powerpc: add support for bpf constant blinding Naveen N. Rao
2016-09-23 21:40 ` Daniel Borkmann
2016-10-05 2:36 ` [1/3] bpf powerpc: introduce accessors for using the tmp local stack space Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57E5ADD2.7090308@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=ananth@in.ibm.com \
--cc=ast@fb.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).