Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1491156

Re: [PATCH 2/3] bpf powerpc: implement support for tail calls

Path csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod
From "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] bpf powerpc: implement support for tail calls
Date Mon, 26 Sep 2016 11:00:01 +0200
Message-ID <slzVv-1EX-7@gated-at.bofh.it> (permalink)
References <skFqi-6t-7@gated-at.bofh.it> <skFqi-6t-13@gated-at.bofh.it> <skHiq-1h5-17@gated-at.bofh.it> <skPIZ-6xi-7@gated-at.bofh.it>
X-Original-To Alexei Starovoitov <alexei.starovoitov@gmail.com>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.6.2 (2016-07-01)
X-Tm-As-Mml disable
X-Content-Scanned Fidelis XPS MAILER
X-Cbid 16092608-0004-0000-0000-0000019EFE92
X-Ibm-Av-Detection SAVI=unused REMOTE=unused XFE=unused
X-Cbparentid 16092608-0005-0000-0000-000008C300E6
X-Proofpoint-Virus-Version vendor=fsecure engine=2.50.10432:,, definitions=2016-09-26_06:,, signatures=0
X-Proofpoint-Spam-Details rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609020000 definitions=main-1609260169
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 44
Organization linux.* mail to news gateway
X-Original-Cc Daniel Borkmann <daniel@iogearbox.net>, Ananth N Mavinakayanahalli <ananth@in.ibm.com>, Alexei Starovoitov <ast@fb.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "David S. Miller" <davem@davemloft.net>
X-Original-Date Mon, 26 Sep 2016 14:26:22 +0530
X-Original-Message-ID <20160926085622.GG15470@naverao1-tp.localdomain>
X-Original-References <40b65ab2bb3a48837ab047a70887de3ccd70c56b.1474661927.git.naveen.n.rao@linux.vnet.ibm.com> <c7c16b999694b2851705d79da939988e521bda3a.1474661927.git.naveen.n.rao@linux.vnet.ibm.com> <57E5ADD2.7090308@iogearbox.net> <20160924073025.GB48071@ast-mbp.thefacebook.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1491156

Show key headers only | View raw


On 2016/09/24 03:30AM, Alexei Starovoitov wrote:
> On Sat, Sep 24, 2016 at 12:33:54AM +0200, Daniel Borkmann wrote:
> > 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!
> 
> Great stuff. In this circumstances approach 2 makes sense to me as well.

Alexie, Daniel,
Thanks for the quick review!

- Naveen

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/3] bpf powerpc: implement support for tail calls "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-09-23 22:40 +0200
  Re: [PATCH 2/3] bpf powerpc: implement support for tail calls Daniel Borkmann <daniel@iogearbox.net> - 2016-09-24 00:40 +0200
    Re: [PATCH 2/3] bpf powerpc: implement support for tail calls Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-09-24 09:40 +0200
      Re: [PATCH 2/3] bpf powerpc: implement support for tail calls "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-09-26 11:00 +0200
        Re: [PATCH 2/3] bpf powerpc: implement support for tail calls "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2016-09-26 11:10 +0200
        Re: [PATCH 2/3] bpf powerpc: implement support for tail calls Daniel Borkmann <daniel@iogearbox.net> - 2016-09-26 11:10 +0200

csiph-web