bnxt: use the NAPI skb allocation cache
Jakub Kicinski
maintainerPATCH 1/1 bnxt: use the NAPI skb allocation cache
All callers of build_skb() (*) in bnxt are in NAPI context. The budget checking is somewhat convoluted because in the shared completion queue cases Rx packets are discarded by netpoll by forcing an error (E). But that happens before skb allocation. Only a call chain starting at __bnxt_poll_work() can lead to an skb allocation and it checks budget (b).
* bnxt_rx_multi_page_skb
* bnxt_rx_skb
` bp->rx_skb_func
* bnxt_tpa_end
` bnxt_rx_pkt
E bnxt_force_rx_discard
E bnxt_poll_nitroa0
b __bnxt_poll_work
Use napi_build_skb() to take advantage of the skb cache. In iperf tests with HW-GRO enabled it barely makes a difference but in cases where HW-GRO is not as effective (or disabled) it can give even a >10% boost (20.7Gbps -> 23.1Gbps).
---
CC: [email protected]
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +3 -3
@@ -994,7 +994,7 @@ static struct sk_buff *bnxt_rx_multi_page_skb(struct bnxt *bp, dma_addr -= bp->rx_dma_offset;dma_sync_single_for_cpu (&bp->pdev->dev, dma_addr,BNXT_RX_PAGE_SIZE , bp->rx_dir); - skb =build_skb (data_ptr - bp->rx_offset,BNXT_RX_PAGE_SIZE ); + skb =napi_build_skb (data_ptr - bp->rx_offset,BNXT_RX_PAGE_SIZE );if (!skb) {page_pool_recycle_direct (rxr->page_pool, page);return NULL ;
@@ -1069,7 +1069,7 @@ static struct sk_buff *bnxt_rx_skb(struct bnxt *bp,return NULL ; } - skb =build_skb (data, bp->rx_buf_size); + skb =napi_build_skb (data, bp->rx_buf_size);dma_unmap_single_attrs (&bp->pdev->dev, dma_addr, bp->rx_buf_use_size, bp->rx_dir,DMA_ATTR_WEAK_ORDERING );if (!skb) {
@@ -1677,7 +1677,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, tpa_info->data_ptr = new_data + bp->rx_offset; tpa_info->mapping = new_mapping; - skb =build_skb (data, bp->rx_buf_size); + skb =napi_build_skb (data, bp->rx_buf_size);dma_unmap_single_attrs (&bp->pdev->dev, mapping, bp->rx_buf_use_size, bp->rx_dir,DMA_ATTR_WEAK_ORDERING );
Signature · 1 line
2.41.0
Quoted 17 lines · Jakub Kicinski
All callers of
build_skb()(*) in bnxt are in NAPI context. The budget checking is somewhat convoluted because in the shared completion queue cases Rx packets are discarded by netpoll by forcing an error (E). But that happens before skb allocation. Only a call chain starting at__bnxt_poll_work()can lead to an skb allocation and it checks budget (b).*
bnxt_rx_multi_page_skb
*bnxt_rx_skb
`bp->rx_skb_func
*bnxt_tpa_end
`bnxt_rx_pkt
Ebnxt_force_rx_discard
Ebnxt_poll_nitroa0
b__bnxt_poll_work
Quoted 6 lines
Use
napi_build_skb()to take advantage of the skb cache. In iperf tests with HW-GRO enabled it barely makes a difference but in cases where HW-GRO is not as effective (or disabled) it can give even a >10% boost (20.7Gbps -> 23.1Gbps).Signed-off-by Jakub Kicinski <[email protected]>
Confirming that build_skb() is always called in NAPI context and budget is checked. Thanks.
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 8 lines · On Tue, 22 Aug 2023 14:51:42 -0700 you wrote:
All callers of
build_skb()(*) in bnxt are in NAPI context. The budget checking is somewhat convoluted because in the shared completion queue cases Rx packets are discarded by netpoll by forcing an error (E). But that happens before skb allocation. Only a call chain starting at__bnxt_poll_work()can lead to an skb allocation and it checks budget (b).[...]
Here is the summary with links:
- [net-next] bnxt: use the NAPI skb allocation cache
https://git.kernel.org/netdev/net-next/c/e3b3a87967ce
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html