[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHS8izPRupVvCDQr7-GF+-c3yeu83wZWgQth4_ub8bQ0AhQ9_w@mail.gmail.com>
Date: Mon, 8 Sep 2025 09:15:07 -0700
From: Mina Almasry <almasrymina@...gle.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
pabeni@...hat.com, andrew+netdev@...n.ch, horms@...nel.org, hawk@...nel.org,
ilias.apalodimas@...aro.org, nathan@...nel.org,
nick.desaulniers+lkml@...il.com, morbo@...gle.com, justinstitt@...gle.com,
llvm@...ts.linux.dev
Subject: Re: [PATCH net-next] page_pool: always add GFP_NOWARN for ATOMIC allocations
On Mon, Sep 8, 2025 at 8:21 AM Jakub Kicinski <kuba@...nel.org> wrote:
>
> Driver authors often forget to add GFP_NOWARN for page allocation
> from the datapath. This is annoying to operators as OOMs are a fact
> of life, and we pretty much expect network Rx to hit page allocation
> failures during OOM. Make page pool add GFP_NOWARN for ATOMIC allocations
> by default.
>
> Don't compare to GFP_ATOMIC because it's a mask with 2 bits set.
> We want a single bit so that the compiler can do an unconditional
> mask and shift. clang builds the condition as:
>
> 1c31: 89 e8 movl %ebp, %eax
> 1c33: 83 e0 20 andl $0x20, %eax
> 1c36: c1 e0 0d shll $0xd, %eax
> 1c39: 09 e8 orl %ebp, %eax
>
> so there seems to be no need any more to use the old flag multiplication
> tricks which is less readable. Pick the lowest bit out of GFP_ATOMIC
> to limit the size of the instructions.
>
> The specific change which makes me propose this is that bnxt, after
> commit cd1fafe7da1f ("eth: bnxt: add support rx side device memory TCP"),
> lost the GFP_NOWARN, again. It used to allocate with page_pool_dev_alloc_*
BTW, there is a page_pool_dev_alloc_netmems now that also add the
NOWARN and should have been devmem tcp compatible and maintained same
behavior I think.
> which added the NOWARN unconditionally. While switching to
> __bnxt_alloc_rx_netmem() authors forgot to add NOWARN in the explicitly
> specified flags.
>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> CC: hawk@...nel.org
> CC: ilias.apalodimas@...aro.org
> CC: nathan@...nel.org
> CC: nick.desaulniers+lkml@...il.com
> CC: morbo@...gle.com
> CC: justinstitt@...gle.com
> CC: llvm@...ts.linux.dev
> ---
> net/core/page_pool.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index ba70569bd4b0..6ffce0e821e4 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -555,6 +555,13 @@ static noinline netmem_ref __page_pool_alloc_netmems_slow(struct page_pool *pool
> netmem_ref netmem;
> int i, nr_pages;
>
> + /* Unconditionally set NOWARN if allocating from the datapath.
> + * Use a single bit from the ATOMIC mask to help compiler optimize.
> + */
> + BUILD_BUG_ON(!(GFP_ATOMIC & __GFP_HIGH));
> + if (gfp & __GFP_HIGH)
> + gfp |= __GFP_NOWARN;
> +
I wonder if pp allocs are ever used for anything other than datapath
pages (and if not, we can add __GPF_NOWARN here unconditionally. But
this is good too I think.
Reviewed-by: Mina Almasry <almasrymina@...gle.com>
--
Thanks,
Mina
Powered by blists - more mailing lists