Re: [PATCH RFC v1 05/15] ixgbe: add XDP frame size to driver

Jesper Dangaard Brouer
2020-03-20T21:44:57Z

On Wed, 18 Mar 2020 14:23:09 -0700
Alexander Duyck <alexander.duyck@gmail.com> wrote:

> On Wed, Mar 18, 2020 at 1:04 PM Maciej Fijalkowski
> <maciej.fijalkowski@intel.com> wrote:
> >
> > On Tue, Mar 17, 2020 at 06:29:33PM +0100, Jesper Dangaard Brouer wrote:
> > > The ixgbe driver uses different memory models depending on PAGE_SIZE at
> > > compile time. For PAGE_SIZE 4K it uses page splitting, meaning for
> > > normal MTU frame size is 2048 bytes (and headroom 192 bytes).
> >
> > To be clear the 2048 is the size of buffer given to HW and we slice it up
> > in a following way:
> > - 192 bytes dedicated for headroom
> > - 1500 is max allowed MTU for this setup
> > - 320 bytes for tailroom (skb shinfo)
> >
> > In case you go with higher MTU then 3K buffer would be used and it would
> > came from order1 page and we still do the half split. Just FYI all of this
> > is for PAGE_SIZE == 4k and L1$ size == 64.
>
> True, but for most people this is the most common case since these are
> the standard for x86.
>
> > > For PAGE_SIZE larger than 4K, driver advance its rx_buffer->page_offset
> > > with the frame size "truesize".
> >
> > Alex, couldn't we base the truesize here somehow on ixgbe_rx_bufsz() since
> > these are the sizes that we are passing to hw? I must admit I haven't been
> > in touch with systems with PAGE_SIZE > 4K.
>
> With a page size greater than 4K we can actually get many more uses
> out of a page by using the frame size to determine the truesize of the
> packet. The truesize is the memory footprint currently being held by
> the packet. So once the packet is filled we just have to add the
> headroom and tailroom to whatever the hardware wrote instead of having
> to use what we gave to the hardware. That gives us better efficiency,
> if we used ixgbe_rx_bufsz() we would penalize small packets and that
> in turn would likely hurt performance.
>
> > >
> > > When driver enable XDP it uses build_skb() which provides the necessary
> > > tailroom for XDP-redirect.
> >
> > We still allow to load XDP prog when ring is not using build_skb(). I have
> > a feeling that we should drop this case now.
> >
> > Alex/John/Bjorn WDYT?
>
> The comment Jesper had about using using build_skb() when XDP is in
> use is incorrect. The two are not correlated. The underlying buffer is
> the same, however we drop the headroom and tailroom if we are in
> _RX_LEGACY mode. We default to build_skb and the option of switching
> to legacy Rx is controlled via the device private flags.

Thanks for catching that.

> However with that said the change itself is mostly harmless, and
> likely helps to resolve issues that would be seen if somebody were to
> enable XDP while having the RX_LEGACY flag set.

So what is the path forward(?). Are you/Intel okay with disallowing
XDP when the RX_LEGACY flag is set?

--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer