On Mon, 18 Jan 2021 18:07:17 +0800
Hangbin Liu <[email protected]> wrote:
> On Sun, Jan 17, 2021 at 02:57:02PM -0800, John Fastabend wrote:
> [...]
> > It looks like we could embed xdp_buff in xdp_frame and then keep the
> > metadata
> > at the end.
> >
> > Because you are working performance here wdyt? <- @Jesper as well.
>
> Leave this question to Jesper.
The struct xdp_buff is larger than struct xdp_frame. The size of
xdp_frame matters. It is a reserved areas in top of the frame.
An XDP BPF-program cannot access this area (and limit headroom grow).
This is why this code works, as afterwards xdp_frame is still valid.
Looking at the code xdp_update_frame_from_buff() we do seem to update
more fields than actually needed.
> > >
> > > - sent = dev->netdev_ops->ndo_xdp_xmit(dev, bq->count, bq->q, flags);
> > > + if (unlikely(bq->xdp_prog)) {
> >
> > Whats the rational for making above unlikely()? Seems for users its not
> > unlikely. Can you measure a performance increase/decrease here? I think
> > its probably fine to just let compiler/prefetcher do its thing here. Or
> > I'm not reading this right, but seems users of bq->xdp_prog would disagree
> > on unlikely case?
> >
> > Either way a comment might be nice to give us some insight in 6 months
> > why we decided this is unlikely.
>
> I agree that there is no need to use unlikely() here.
I added the unlikely() to preserve the baseline performance when not
having the 2nd prog loaded. But I'm fine with removing that.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer