Re: [PATCH v5 RFC 2/6] page_pool: unify frag_count handling in page_pool_is_last_frag()

From: Alexander Lobakin
Date: Mon Jul 10 2023 - 10:40:17 EST


From: Yunsheng Lin <linyunsheng@xxxxxxxxxx>
Date: Thu, 29 Jun 2023 20:02:22 +0800

> Currently when page_pool_create() is called with
> PP_FLAG_PAGE_FRAG flag, page_pool_alloc_pages() is only
> allowed to be called under the below constraints:
> 1. page_pool_fragment_page() need to be called to setup
> page->pp_frag_count immediately.
> 2. page_pool_defrag_page() often need to be called to drain
> the page->pp_frag_count when there is no more user will
> be holding on to that page.

[...]

> @@ -352,12 +377,10 @@ static inline bool page_pool_is_last_frag(struct page_pool *pool,
> {
> /* We assume we are the last frag user that is still holding
> * on to the page if:
> - * 1. Fragments aren't enabled.
> - * 2. We are running in 32-bit arch with 64-bit DMA.
> - * 3. page_pool_defrag_page() indicate we are the last user.
> + * 1. We are running in 32-bit arch with 64-bit DMA.
> + * 2. page_pool_defrag_page() indicate we are the last user.
> */
> - return !(pool->p.flags & PP_FLAG_PAGE_FRAG) ||
> - PAGE_POOL_DMA_USE_PP_FRAG_COUNT ||
> + return PAGE_POOL_DMA_USE_PP_FRAG_COUNT ||
> (page_pool_defrag_page(page, 1) == 0);

Just noticed while developing: after this change, the first function
argument, i.e. @pool, is not needed anymore and can be removed.

[...]

Thanks,
Olek