Re: [PATCH net-next] page pool: not return page to alloc cache during pool destruction

From: Yunsheng Lin
Date: Thu Jun 15 2023 - 05:06:47 EST


On 2023/6/15 17:01, Yunsheng Lin wrote:
> On 2023/6/15 9:36, Liang Chen wrote:
>> When destroying a page pool, the alloc cache and recycle ring are emptied.
>> If there are inflight pages, the retry process will periodically check the
>> recycle ring for recently returned pages, but not the alloc cache (alloc
>> cache is only emptied once). As a result, any pages returned to the alloc
>> cache after the page pool destruction will be stuck there and cause the
>> retry process to continuously look for inflight pages and report warnings.
>
> It seems there is still page_pool_put[_full]_page() called with
> allow_direct being true after page_pool_destroy() is call, which
> is not allowed.
>
> Normally the driver will call napi_disable() before
> page_pool_destroy() to ensure there is no such page_pool_destroy()

no such page_pool_put[_full]_page()

> calling with allow_direct being true after page_pool_destroy() is
> called.
>
>>
>> To safeguard against this situation, any pages returning to the alloc cache
>> after pool destruction should be prevented.
>>
>> Signed-off-by: Liang Chen <liangchen.linux@xxxxxxxxx>
>> ---
>> net/core/page_pool.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
>> index a3e12a61d456..76255313d349 100644
>> --- a/net/core/page_pool.c
>> +++ b/net/core/page_pool.c
>> @@ -595,7 +595,7 @@ __page_pool_put_page(struct page_pool *pool, struct page *page,
>> page_pool_dma_sync_for_device(pool, page,
>> dma_sync_size);
>>
>> - if (allow_direct && in_softirq() &&
>> + if (allow_direct && in_softirq() && !pool->destroy_cnt &&
>
> The checking seems racy when __page_pool_put_page() and
> page_pool_destroy() are called concurently.
>
>> page_pool_recycle_in_cache(page, pool))
>> return NULL;
>>
>>
>
>
> .
>