Skip to contentSkip to conversation

net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled

PATCH Superseded Furong Xu 2 participants 2 messages Sep 13, 2024 – Sep 19, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Furong Xu

author
#0 lore raw

PATCH 1/1 net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled

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

This patch brings up to 9% noticeable performance improvement on certain platforms.

Fixes 5fabb01207a2 ("net: stmmac: Add initial XDP support")
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
index f3a1b179aaea..95d3d1081727 100644
@@ -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);
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 10 lines · Furong Xu

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

This patch brings up to 9% noticeable performance improvement on certain platforms.

Fixes 5fabb01207a2 ("net: stmmac: Add initial XDP support")

I'm quite unconvinced that every performance improvement would be eligible to be considered a fix.

Reading the code it looks like this change actually addresses a regression introduced by the blamed commit, is that correct? If so please re-phrase the commit message accordingly.

Thanks,

Paolo