[lkml]   [2021]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH net-next v3 0/5] page_pool: recycle buffers
Hi Yunsheng,

On Thu, Apr 29, 2021 at 04:27:21PM +0800, Yunsheng Lin wrote:
> On 2021/4/10 6:37, Matteo Croce wrote:
> > From: Matteo Croce <>
> >
> > This is a respin of [1]
> >
> > This patchset shows the plans for allowing page_pool to handle and
> > maintain DMA map/unmap of the pages it serves to the driver. For this
> > to work a return hook in the network core is introduced.
> >
> > The overall purpose is to simplify drivers, by providing a page
> > allocation API that does recycling, such that each driver doesn't have
> > to reinvent its own recycling scheme. Using page_pool in a driver
> > does not require implementing XDP support, but it makes it trivially
> > easy to do so. Instead of allocating buffers specifically for SKBs
> > we now allocate a generic buffer and either wrap it on an SKB
> > (via build_skb) or create an XDP frame.
> > The recycling code leverages the XDP recycle APIs.
> >
> > The Marvell mvpp2 and mvneta drivers are used in this patchset to
> > demonstrate how to use the API, and tested on a MacchiatoBIN
> > and EspressoBIN boards respectively.
> >
> Hi, Matteo
> I added the skb frag page recycling in hns3 based on this patchset,
> and it has above 10%~20% performance improvement for one thread iperf
> TCP flow(IOMMU is off, there may be more performance improvement if
> considering the DMA map/unmap avoiding for IOMMU), thanks for the job.
> The skb frag page recycling support in hns3 driver is not so simple
> as the mvpp2 and mvneta driver, because:
> 1. the hns3 driver do not have XDP support yet, so "struct xdp_rxq_info"
> is added to assist relation binding between the "struct page" and
> "struct page_pool".
> 2. the hns3 driver has already a page reusing based on page spliting and
> page reference count, but it may not work if the upper stack can not
> handle skb and release the corresponding page fast enough.
> 3. the hns3 driver support page reference count updating batching, see:
> aeda9bf87a45 ("net: hns3: batch the page reference count updates")
> So it would be better if:
> 1. skb frag page recycling do not need "struct xdp_rxq_info" or
> "struct xdp_mem_info" to bond the relation between "struct page" and
> "struct page_pool", which seems uncessary at this point if bonding
> a "struct page_pool" pointer directly in "struct page" does not cause
> space increasing.

We can't do that. The reason we need those structs is that we rely on the
existing XDP code, which already recycles it's buffers, to enable
recycling. Since we allocate a page per packet when using page_pool for a
driver , the same ideas apply to an SKB and XDP frame. We just recycle the
payload and we don't really care what's in that. We could rename the functions
to something more generic in the future though ?

> 2. it would be good to do the page reference count updating batching
> in page pool instead of specific driver.
> page_pool_atomic_sub_if_positive() is added to decide who can call
> page_pool_put_full_page(), because the driver and stack may hold
> reference to the same page, only if last one which hold complete
> reference to a page can call page_pool_put_full_page() to decide if
> recycling is possible, if not, the page is released, so I am wondering
> if a similar page_pool_atomic_sub_if_positive() can added to specific
> user space address unmapping path to allow skb recycling for RX zerocopy
> too?

I would prefer a different page pool type if we wanted to support the split
page model. The changes as is are quite intrusive, since they change the
entire skb return path. So I would prefer introducing the changes one at a

The fundamental difference between having the recycling in the driver vs
having it in a generic API is pretty straightforward. When a driver holds
the extra page references he is free to decide what to reuse, when he is about
to refill his Rx descriptors. So TCP zerocopy might work even if the
userspace applications hold the buffers for an X amount of time.
On this proposal though we *need* to decide what to do with the buffer when we
are about to free the skb.



 \ /
  Last update: 2021-04-29 20:52    [W:0.162 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site