netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] bnxt: make sure we return pages to the pool
@ 2023-01-11  4:25 Jakub Kicinski
  2023-01-11 14:22 ` Andy Gospodarek
  2023-01-12  5:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2023-01-11  4:25 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, somnath.kotur, andrew.gospodarek,
	michael.chan, Jakub Kicinski

Before the commit under Fixes the page would have been released
from the pool before the napi_alloc_skb() call, so normal page
freeing was fine (released page == no longer in the pool).

After the change we just mark the page for recycling so it's still
in the pool if the skb alloc fails, we need to recycle.

Same commit added the same bug in the new bnxt_rx_multi_page_skb().

Fixes: 1dc4c557bfed ("bnxt: adding bnxt_xdp_build_skb to build skb from multibuffer xdp_buff")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 16ce7a90610c..240a7e8a7652 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -993,7 +993,7 @@ static struct sk_buff *bnxt_rx_multi_page_skb(struct bnxt *bp,
 			     DMA_ATTR_WEAK_ORDERING);
 	skb = build_skb(page_address(page), PAGE_SIZE);
 	if (!skb) {
-		__free_page(page);
+		page_pool_recycle_direct(rxr->page_pool, page);
 		return NULL;
 	}
 	skb_mark_for_recycle(skb);
@@ -1031,7 +1031,7 @@ static struct sk_buff *bnxt_rx_page_skb(struct bnxt *bp,
 
 	skb = napi_alloc_skb(&rxr->bnapi->napi, payload);
 	if (!skb) {
-		__free_page(page);
+		page_pool_recycle_direct(rxr->page_pool, page);
 		return NULL;
 	}
 
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] bnxt: make sure we return pages to the pool
  2023-01-11  4:25 [PATCH net] bnxt: make sure we return pages to the pool Jakub Kicinski
@ 2023-01-11 14:22 ` Andy Gospodarek
  2023-01-12  5:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Gospodarek @ 2023-01-11 14:22 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, somnath.kotur,
	andrew.gospodarek, michael.chan

On Tue, Jan 10, 2023 at 08:25:47PM -0800, Jakub Kicinski wrote:
> Before the commit under Fixes the page would have been released
> from the pool before the napi_alloc_skb() call, so normal page
> freeing was fine (released page == no longer in the pool).
> 
> After the change we just mark the page for recycling so it's still
> in the pool if the skb alloc fails, we need to recycle.
> 
> Same commit added the same bug in the new bnxt_rx_multi_page_skb().

Good catch, thank you.

> Fixes: 1dc4c557bfed ("bnxt: adding bnxt_xdp_build_skb to build skb from multibuffer xdp_buff")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Andy Gospodarek <gospo@broadcom.com>

> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 16ce7a90610c..240a7e8a7652 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -993,7 +993,7 @@ static struct sk_buff *bnxt_rx_multi_page_skb(struct bnxt *bp,
>  			     DMA_ATTR_WEAK_ORDERING);
>  	skb = build_skb(page_address(page), PAGE_SIZE);
>  	if (!skb) {
> -		__free_page(page);
> +		page_pool_recycle_direct(rxr->page_pool, page);
>  		return NULL;
>  	}
>  	skb_mark_for_recycle(skb);
> @@ -1031,7 +1031,7 @@ static struct sk_buff *bnxt_rx_page_skb(struct bnxt *bp,
>  
>  	skb = napi_alloc_skb(&rxr->bnapi->napi, payload);
>  	if (!skb) {
> -		__free_page(page);
> +		page_pool_recycle_direct(rxr->page_pool, page);
>  		return NULL;
>  	}
>  
> -- 
> 2.38.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] bnxt: make sure we return pages to the pool
  2023-01-11  4:25 [PATCH net] bnxt: make sure we return pages to the pool Jakub Kicinski
  2023-01-11 14:22 ` Andy Gospodarek
@ 2023-01-12  5:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-12  5:00 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, somnath.kotur,
	andrew.gospodarek, michael.chan

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 10 Jan 2023 20:25:47 -0800 you wrote:
> Before the commit under Fixes the page would have been released
> from the pool before the napi_alloc_skb() call, so normal page
> freeing was fine (released page == no longer in the pool).
> 
> After the change we just mark the page for recycling so it's still
> in the pool if the skb alloc fails, we need to recycle.
> 
> [...]

Here is the summary with links:
  - [net] bnxt: make sure we return pages to the pool
    https://git.kernel.org/netdev/net/c/97f5e03a4a27

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-12  5:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11  4:25 [PATCH net] bnxt: make sure we return pages to the pool Jakub Kicinski
2023-01-11 14:22 ` Andy Gospodarek
2023-01-12  5:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).