[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <66aaf22e-5b0b-b67c-bb71-c61b966c0d5c@redhat.com>
Date: Thu, 20 Apr 2023 10:56:22 +0200
From: Jesper Dangaard Brouer <jbrouer@...hat.com>
To: Jakub Kicinski <kuba@...nel.org>, davem@...emloft.net
Cc: brouer@...hat.com, netdev@...r.kernel.org, edumazet@...gle.com,
pabeni@...hat.com, Jesper Dangaard Brouer <jbrouer@...hat.com>,
hawk@...nel.org, ilias.apalodimas@...aro.org, tariqt@...dia.com
Subject: Re: [PATCH net-next] page_pool: unlink from napi during destroy
On 19/04/2023 20.20, Jakub Kicinski wrote:
> Jesper points out that we must prevent recycling into cache
> after page_pool_destroy() is called, because page_pool_destroy()
> is not synchronized with recycling (some pages may still be
> outstanding when destroy() gets called).
>
> I assumed this will not happen because NAPI can't be scheduled
> if its page pool is being destroyed. But I missed the fact that
> NAPI may get reused. For instance when user changes ring configuration
> driver may allocate a new page pool, stop NAPI, swap, start NAPI,
> and then destroy the old pool. The NAPI is running so old page
> pool will think it can recycle to the cache, but the consumer
> at that point is the destroy() path, not NAPI.
>
> To avoid extra synchronization let the drivers do "unlinking"
> during the "swap" stage while NAPI is indeed disabled.
>
> Fixes: 8c48eea3adf3 ("page_pool: allow caching from safely localized NAPI")
> Reported-by: Jesper Dangaard Brouer <jbrouer@...hat.com>
> Link: https://lore.kernel.org/all/e8df2654-6a5b-3c92-489d-2fe5e444135f@redhat.com/
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> bnxt does not do the live swap so no need to change it.
> But let's export the API, anyway, I'm sure others will
> need it. And knowing driver authors they will hack some
> workaround into the driver rather than export the helper.
>
> CC: hawk@...nel.org
> CC: ilias.apalodimas@...aro.org
> CC: tariqt@...dia.com
> ---
> include/net/page_pool.h | 5 +++++
> net/core/page_pool.c | 18 +++++++++++++++++-
> 2 files changed, 22 insertions(+), 1 deletion(-)
>
Acked-by: Jesper Dangaard Brouer <brouer@...hat.com>
Thanks for fixing this.
Powered by blists - more mailing lists