Re: [PATCH RFC net-next 2/3] net: page_pool: use alloc_pages_bulk in refill code path

From: Jesper Dangaard Brouer
Date: Fri Feb 26 2021 - 09:34:25 EST


On Wed, 24 Feb 2021 22:15:22 +0200
Ilias Apalodimas <ilias.apalodimas@xxxxxxxxxx> wrote:

> Hi Jesper,
>
> On Wed, Feb 24, 2021 at 07:56:46PM +0100, Jesper Dangaard Brouer wrote:
> > There are cases where the page_pool need to refill with pages from the
> > page allocator. Some workloads cause the page_pool to release pages
> > instead of recycling these pages.
> >
> > For these workload it can improve performance to bulk alloc pages from
> > the page-allocator to refill the alloc cache.
> >
> > For XDP-redirect workload with 100G mlx5 driver (that use page_pool)
> > redirecting xdp_frame packets into a veth, that does XDP_PASS to create
> > an SKB from the xdp_frame, which then cannot return the page to the
> > page_pool. In this case, we saw[1] an improvement of 18.8% from using
> > the alloc_pages_bulk API (3,677,958 pps -> 4,368,926 pps).
> >
> > [1] https://github.com/xdp-project/xdp-project/blob/master/areas/mem/page_pool06_alloc_pages_bulk.org
> >
> > Signed-off-by: Jesper Dangaard Brouer <brouer@xxxxxxxxxx>
>
> [...]
>
> > + /* Remaining pages store in alloc.cache */
> > + list_for_each_entry_safe(page, next, &page_list, lru) {
> > + list_del(&page->lru);
> > + if (pp_flags & PP_FLAG_DMA_MAP) {
> > + page = page_pool_dma_map(pool, page);
> > + if (!page)
>
> As I commented on the previous patch, i'd prefer the put_page() here to be
> explicitly called, instead of hiding in the page_pool_dma_map()

I fully agree. I will fixup the code.

> > + continue;
> > + }
> > + if (likely(pool->alloc.count < PP_ALLOC_CACHE_SIZE)) {
> > + pool->alloc.cache[pool->alloc.count++] = page;
> > + pool->pages_state_hold_cnt++;
> > + trace_page_pool_state_hold(pool, page,
> > + pool->pages_state_hold_cnt);
> > + } else {
> > + put_page(page);
> > + }
> > + }
> > +out:
> > if (pool->p.flags & PP_FLAG_DMA_MAP) {
> > - page = page_pool_dma_map(pool, page);
> > - if (!page)
> > + first_page = page_pool_dma_map(pool, first_page);
> > + if (!first_page)
> > return NULL;
> > }
> >
> [...]

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