From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesper Dangaard Brouer Subject: Re: [bpf-next V4 PATCH 1/8] bpf: devmap introduce dev_map_enqueue Date: Wed, 23 May 2018 13:12:09 +0200 Message-ID: <20180523131209.553a9089@redhat.com> References: <152665044141.21055.1276346542020340263.stgit@firesoul> <152665047666.21055.16395048652428831814.stgit@firesoul> <1cb01875-6044-540a-e1f8-0cafd9587ee8@iogearbox.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, Daniel Borkmann , Alexei Starovoitov , Christoph Hellwig , =?UTF-8?B?QmrDtnJuVMO2cGVs?= , Magnus Karlsson , makita.toshiaki@lab.ntt.co.jp, brouer@redhat.com To: Daniel Borkmann Return-path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58166 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932391AbeEWLMO (ORCPT ); Wed, 23 May 2018 07:12:14 -0400 In-Reply-To: <1cb01875-6044-540a-e1f8-0cafd9587ee8@iogearbox.net> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, 23 May 2018 11:34:22 +0200 Daniel Borkmann wrote: > > +int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp) > > +{ > > + struct net_device *dev = dst->dev; > > + struct xdp_frame *xdpf; > > + int err; > > + > > + if (!dev->netdev_ops->ndo_xdp_xmit) > > + return -EOPNOTSUPP; > > + > > + xdpf = convert_to_xdp_frame(xdp); > > + if (unlikely(!xdpf)) > > + return -EOVERFLOW; > > + > > + /* TODO: implement a bulking/enqueue step later */ > > + err = dev->netdev_ops->ndo_xdp_xmit(dev, xdpf); > > + if (err) > > + return err; > > + > > + return 0; > > The 'err' is just unnecessary, lets just do: > > return dev->netdev_ops->ndo_xdp_xmit(dev, xdpf); > > Later after the other patches this becomes: > > return bq_enqueue(dst, xdpf, dev_rx); I agree, I'll fix this up in V5. After this patchset gets applied, there are also other opportunities to do similar micro-optimizations. I have a branch (on top of this patchset) which does such micro-optimizations (including this) plus I've looked at the resulting asm-code layout. But my benchmarks only show a 2 nanosec improvement for all these micro-optimizations (where the focus is to reduce the asm-code I-cache size of xdp_do_redirect). -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer