netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled
@ 2024-09-19 12:10 Furong Xu
  2024-09-26  8:50 ` patchwork-bot+netdevbpf
  2024-10-01 10:22 ` Jon Hunter
  0 siblings, 2 replies; 4+ messages in thread
From: Furong Xu @ 2024-09-19 12:10 UTC (permalink / raw)
  To: Ong Boon Leong, David S. Miller, Alexandre Torgue, Jose Abreu,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
	Joao Pinto
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, rmk+kernel,
	linux, xfr, Furong Xu

Commit 5fabb01207a2 ("net: stmmac: Add initial XDP support") sets
PP_FLAG_DMA_SYNC_DEV flag for page_pool unconditionally,
page_pool_recycle_direct() will call page_pool_dma_sync_for_device()
on every page even the page is not going to be reused by XDP program.

When XDP is not enabled, the page which holds the received buffer
will be recycled once the buffer is copied into new SKB by
skb_copy_to_linear_data(), then the MAC core will never reuse this
page any longer. Always setting PP_FLAG_DMA_SYNC_DEV wastes CPU cycles
on unnecessary calling of page_pool_dma_sync_for_device().

After this patch, up to 9% noticeable performance improvement was observed
on certain platforms.

Fixes: 5fabb01207a2 ("net: stmmac: Add initial XDP support")
Signed-off-by: Furong Xu <0x1207@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f3a1b179aaea..95d3d1081727 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2022,7 +2022,7 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv,
 	rx_q->queue_index = queue;
 	rx_q->priv_data = priv;
 
-	pp_params.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
+	pp_params.flags = PP_FLAG_DMA_MAP | (xdp_prog ? PP_FLAG_DMA_SYNC_DEV : 0);
 	pp_params.pool_size = dma_conf->dma_rx_size;
 	num_pages = DIV_ROUND_UP(dma_conf->dma_buf_sz, PAGE_SIZE);
 	pp_params.order = ilog2(num_pages);
-- 
2.34.1


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

* Re: [PATCH net v2] net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled
  2024-09-19 12:10 [PATCH net v2] net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled Furong Xu
@ 2024-09-26  8:50 ` patchwork-bot+netdevbpf
  2024-10-01 10:22 ` Jon Hunter
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-26  8:50 UTC (permalink / raw)
  To: Furong Xu
  Cc: boon.leong.ong, davem, alexandre.torgue, joabreu, edumazet, kuba,
	pabeni, mcoquelin.stm32, jpinto, netdev, linux-stm32,
	linux-arm-kernel, linux-kernel, rmk+kernel, linux, xfr

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Thu, 19 Sep 2024 20:10:28 +0800 you wrote:
> Commit 5fabb01207a2 ("net: stmmac: Add initial XDP support") sets
> PP_FLAG_DMA_SYNC_DEV flag for page_pool unconditionally,
> page_pool_recycle_direct() will call page_pool_dma_sync_for_device()
> on every page even the page is not going to be reused by XDP program.
> 
> When XDP is not enabled, the page which holds the received buffer
> will be recycled once the buffer is copied into new SKB by
> skb_copy_to_linear_data(), then the MAC core will never reuse this
> page any longer. Always setting PP_FLAG_DMA_SYNC_DEV wastes CPU cycles
> on unnecessary calling of page_pool_dma_sync_for_device().
> 
> [...]

Here is the summary with links:
  - [net,v2] net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled
    https://git.kernel.org/netdev/net/c/b514c47ebf41

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] 4+ messages in thread

* Re: [PATCH net v2] net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled
  2024-09-19 12:10 [PATCH net v2] net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled Furong Xu
  2024-09-26  8:50 ` patchwork-bot+netdevbpf
@ 2024-10-01 10:22 ` Jon Hunter
  2024-10-04 14:08   ` Jakub Kicinski
  1 sibling, 1 reply; 4+ messages in thread
From: Jon Hunter @ 2024-10-01 10:22 UTC (permalink / raw)
  To: Furong Xu, Ong Boon Leong, David S. Miller, Alexandre Torgue,
	Jose Abreu, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, Joao Pinto
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, rmk+kernel,
	linux, xfr, linux-tegra@vger.kernel.org, regressions,
	Thierry Reding

Hi Furong,

On 19/09/2024 13:10, Furong Xu wrote:
> Commit 5fabb01207a2 ("net: stmmac: Add initial XDP support") sets
> PP_FLAG_DMA_SYNC_DEV flag for page_pool unconditionally,
> page_pool_recycle_direct() will call page_pool_dma_sync_for_device()
> on every page even the page is not going to be reused by XDP program.
> 
> When XDP is not enabled, the page which holds the received buffer
> will be recycled once the buffer is copied into new SKB by
> skb_copy_to_linear_data(), then the MAC core will never reuse this
> page any longer. Always setting PP_FLAG_DMA_SYNC_DEV wastes CPU cycles
> on unnecessary calling of page_pool_dma_sync_for_device().
> 
> After this patch, up to 9% noticeable performance improvement was observed
> on certain platforms.
> 
> Fixes: 5fabb01207a2 ("net: stmmac: Add initial XDP support")
> Signed-off-by: Furong Xu <0x1207@gmail.com>
> ---
>   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index f3a1b179aaea..95d3d1081727 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2022,7 +2022,7 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv,
>   	rx_q->queue_index = queue;
>   	rx_q->priv_data = priv;
>   
> -	pp_params.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
> +	pp_params.flags = PP_FLAG_DMA_MAP | (xdp_prog ? PP_FLAG_DMA_SYNC_DEV : 0);
>   	pp_params.pool_size = dma_conf->dma_rx_size;
>   	num_pages = DIV_ROUND_UP(dma_conf->dma_buf_sz, PAGE_SIZE);
>   	pp_params.order = ilog2(num_pages);


We have noticed a boot regression in both -next and mainline v6.12-rc1. 
Bisect is pointing to this commit. Reverting this commit fixes the problem.

This boot regression is seen on our Tegra234 Jetson AGX Orin platform 
that uses the drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c driver. 
We are booting with NFS and although the network interface does come up, 
we fail to mount the rootfs via NFS.

So it would appear that we need to set this flag for this device. Any 
thoughts?

Thanks
Jon

-- 
nvpublic

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

* Re: [PATCH net v2] net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled
  2024-10-01 10:22 ` Jon Hunter
@ 2024-10-04 14:08   ` Jakub Kicinski
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2024-10-04 14:08 UTC (permalink / raw)
  To: Jon Hunter
  Cc: Furong Xu, Ong Boon Leong, David S. Miller, Alexandre Torgue,
	Jose Abreu, Eric Dumazet, Paolo Abeni, Maxime Coquelin,
	Joao Pinto, netdev, linux-stm32, linux-arm-kernel, linux-kernel,
	rmk+kernel, linux, xfr, linux-tegra@vger.kernel.org, regressions,
	Thierry Reding

On Tue, 1 Oct 2024 11:22:32 +0100 Jon Hunter wrote:
> We have noticed a boot regression in both -next and mainline v6.12-rc1. 
> Bisect is pointing to this commit. Reverting this commit fixes the problem.
> 
> This boot regression is seen on our Tegra234 Jetson AGX Orin platform 
> that uses the drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c driver. 
> We are booting with NFS and although the network interface does come up, 
> we fail to mount the rootfs via NFS.
> 
> So it would appear that we need to set this flag for this device. Any 
> thoughts?

This patch doesn't make sense to me. I'll send a revert shortly.

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

end of thread, other threads:[~2024-10-04 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-19 12:10 [PATCH net v2] net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled Furong Xu
2024-09-26  8:50 ` patchwork-bot+netdevbpf
2024-10-01 10:22 ` Jon Hunter
2024-10-04 14:08   ` Jakub Kicinski

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).