* [PATCH] bcm63xx_enet: reuse skbuff_head
@ 2022-06-14 2:10 Sieng Piaw Liew
2022-06-14 16:12 ` Florian Fainelli
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Sieng Piaw Liew @ 2022-06-14 2:10 UTC (permalink / raw)
To: davem, edumazet, kuba, f.fainelli, bcm-kernel-feedback-list,
netdev, linux-kernel
Cc: Sieng Piaw Liew
napi_build_skb() reuses NAPI skbuff_head cache in order to save some
cycles on freeing/allocating skbuff_heads on every new Rx or completed
Tx.
Use napi_consume_skb() to feed the cache with skbuff_heads of completed
Tx so it's never empty.
Signed-off-by: Sieng Piaw Liew <liew.s.piaw@gmail.com>
---
drivers/net/ethernet/broadcom/bcm63xx_enet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 698438a2ee0f..514d61dd91c7 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -388,7 +388,7 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
priv->rx_buf_size, DMA_FROM_DEVICE);
priv->rx_buf[desc_idx] = NULL;
- skb = build_skb(buf, priv->rx_frag_size);
+ skb = napi_build_skb(buf, priv->rx_frag_size);
if (unlikely(!skb)) {
skb_free_frag(buf);
dev->stats.rx_dropped++;
@@ -468,7 +468,7 @@ static int bcm_enet_tx_reclaim(struct net_device *dev, int force)
dev->stats.tx_errors++;
bytes += skb->len;
- dev_kfree_skb(skb);
+ napi_consume_skb(skb, !force);
released++;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] bcm63xx_enet: reuse skbuff_head
2022-06-14 2:10 [PATCH] bcm63xx_enet: reuse skbuff_head Sieng Piaw Liew
@ 2022-06-14 16:12 ` Florian Fainelli
2022-06-15 4:50 ` Jakub Kicinski
2022-06-15 6:09 ` [PATCH V2] bcm63xx_enet: switch to napi_build_skb() to reuse skbuff_heads Sieng Piaw Liew
2 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2022-06-14 16:12 UTC (permalink / raw)
To: Sieng Piaw Liew, davem, edumazet, kuba, f.fainelli,
bcm-kernel-feedback-list, netdev, linux-kernel
On 6/13/22 19:10, Sieng Piaw Liew wrote:
> napi_build_skb() reuses NAPI skbuff_head cache in order to save some
> cycles on freeing/allocating skbuff_heads on every new Rx or completed
> Tx.
> Use napi_consume_skb() to feed the cache with skbuff_heads of completed
> Tx so it's never empty.
>
> Signed-off-by: Sieng Piaw Liew <liew.s.piaw@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] bcm63xx_enet: reuse skbuff_head
2022-06-14 2:10 [PATCH] bcm63xx_enet: reuse skbuff_head Sieng Piaw Liew
2022-06-14 16:12 ` Florian Fainelli
@ 2022-06-15 4:50 ` Jakub Kicinski
2022-06-15 6:09 ` [PATCH V2] bcm63xx_enet: switch to napi_build_skb() to reuse skbuff_heads Sieng Piaw Liew
2 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2022-06-15 4:50 UTC (permalink / raw)
To: Sieng Piaw Liew
Cc: davem, edumazet, f.fainelli, bcm-kernel-feedback-list, netdev,
linux-kernel
On Tue, 14 Jun 2022 10:10:09 +0800 Sieng Piaw Liew wrote:
> Subject: [PATCH] bcm63xx_enet: reuse skbuff_head
Please improve the subject. One verb and one vaguely correct noun
is not good enough.
> napi_build_skb() reuses NAPI skbuff_head cache in order to save some
> cycles on freeing/allocating skbuff_heads on every new Rx or completed
> Tx.
> Use napi_consume_skb() to feed the cache with skbuff_heads of completed
> Tx so it's never empty.
>
> Signed-off-by: Sieng Piaw Liew <liew.s.piaw@gmail.com>
Please keep Florian's Ack when posting v2.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V2] bcm63xx_enet: switch to napi_build_skb() to reuse skbuff_heads
2022-06-14 2:10 [PATCH] bcm63xx_enet: reuse skbuff_head Sieng Piaw Liew
2022-06-14 16:12 ` Florian Fainelli
2022-06-15 4:50 ` Jakub Kicinski
@ 2022-06-15 6:09 ` Sieng Piaw Liew
2022-06-15 12:10 ` patchwork-bot+netdevbpf
2022-07-08 8:03 ` [PATCH] bcm63xx: fix Tx cleanup when NAPI poll budget is zero Sieng-Piaw Liew
2 siblings, 2 replies; 7+ messages in thread
From: Sieng Piaw Liew @ 2022-06-15 6:09 UTC (permalink / raw)
To: davem, edumazet, kuba, f.fainelli, bcm-kernel-feedback-list,
netdev, linux-kernel
Cc: Sieng Piaw Liew
napi_build_skb() reuses NAPI skbuff_head cache in order to save some
cycles on freeing/allocating skbuff_heads on every new Rx or completed
Tx.
Use napi_consume_skb() to feed the cache with skbuff_heads of completed
Tx so it's never empty.
Signed-off-by: Sieng Piaw Liew <liew.s.piaw@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/ethernet/broadcom/bcm63xx_enet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 698438a2ee0f..514d61dd91c7 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -388,7 +388,7 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
priv->rx_buf_size, DMA_FROM_DEVICE);
priv->rx_buf[desc_idx] = NULL;
- skb = build_skb(buf, priv->rx_frag_size);
+ skb = napi_build_skb(buf, priv->rx_frag_size);
if (unlikely(!skb)) {
skb_free_frag(buf);
dev->stats.rx_dropped++;
@@ -468,7 +468,7 @@ static int bcm_enet_tx_reclaim(struct net_device *dev, int force)
dev->stats.tx_errors++;
bytes += skb->len;
- dev_kfree_skb(skb);
+ napi_consume_skb(skb, !force);
released++;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V2] bcm63xx_enet: switch to napi_build_skb() to reuse skbuff_heads
2022-06-15 6:09 ` [PATCH V2] bcm63xx_enet: switch to napi_build_skb() to reuse skbuff_heads Sieng Piaw Liew
@ 2022-06-15 12:10 ` patchwork-bot+netdevbpf
2022-07-08 8:03 ` [PATCH] bcm63xx: fix Tx cleanup when NAPI poll budget is zero Sieng-Piaw Liew
1 sibling, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-06-15 12:10 UTC (permalink / raw)
To: Sieng Piaw Liew
Cc: davem, edumazet, kuba, f.fainelli, bcm-kernel-feedback-list,
netdev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Wed, 15 Jun 2022 14:09:22 +0800 you wrote:
> napi_build_skb() reuses NAPI skbuff_head cache in order to save some
> cycles on freeing/allocating skbuff_heads on every new Rx or completed
> Tx.
> Use napi_consume_skb() to feed the cache with skbuff_heads of completed
> Tx so it's never empty.
>
> Signed-off-by: Sieng Piaw Liew <liew.s.piaw@gmail.com>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
>
> [...]
Here is the summary with links:
- [V2] bcm63xx_enet: switch to napi_build_skb() to reuse skbuff_heads
https://git.kernel.org/netdev/net-next/c/c63c615e22eb
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] 7+ messages in thread
* [PATCH] bcm63xx: fix Tx cleanup when NAPI poll budget is zero
2022-06-15 6:09 ` [PATCH V2] bcm63xx_enet: switch to napi_build_skb() to reuse skbuff_heads Sieng Piaw Liew
2022-06-15 12:10 ` patchwork-bot+netdevbpf
@ 2022-07-08 8:03 ` Sieng-Piaw Liew
2022-07-11 20:40 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 7+ messages in thread
From: Sieng-Piaw Liew @ 2022-07-08 8:03 UTC (permalink / raw)
To: davem, kuba, f.fainelli, bcm-kernel-feedback-list, netdev, linux-kernel
Cc: Sieng-Piaw Liew
NAPI poll() function may be passed a budget value of zero, i.e. during
netpoll, which isn't NAPI context.
Therefore, napi_consume_skb() must be given budget value instead of
!force to truly discern netpoll-like scenarios.
Fixes: c63c615e22eb ("bcm63xx_enet: switch to napi_build_skb() to reuse skbuff_heads")
Signed-off-by: Sieng-Piaw Liew <liew.s.piaw@gmail.com>
---
drivers/net/ethernet/broadcom/bcm63xx_enet.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 514d61dd91c7..193dc1db0f4e 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -423,7 +423,7 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
/*
* try to or force reclaim of transmitted buffers
*/
-static int bcm_enet_tx_reclaim(struct net_device *dev, int force)
+static int bcm_enet_tx_reclaim(struct net_device *dev, int force, int budget)
{
struct bcm_enet_priv *priv;
unsigned int bytes;
@@ -468,7 +468,7 @@ static int bcm_enet_tx_reclaim(struct net_device *dev, int force)
dev->stats.tx_errors++;
bytes += skb->len;
- napi_consume_skb(skb, !force);
+ napi_consume_skb(skb, budget);
released++;
}
@@ -499,7 +499,7 @@ static int bcm_enet_poll(struct napi_struct *napi, int budget)
ENETDMAC_IR, priv->tx_chan);
/* reclaim sent skb */
- bcm_enet_tx_reclaim(dev, 0);
+ bcm_enet_tx_reclaim(dev, 0, budget);
spin_lock(&priv->rx_lock);
rx_work_done = bcm_enet_receive_queue(dev, budget);
@@ -1211,7 +1211,7 @@ static int bcm_enet_stop(struct net_device *dev)
bcm_enet_disable_mac(priv);
/* force reclaim of all tx buffers */
- bcm_enet_tx_reclaim(dev, 1);
+ bcm_enet_tx_reclaim(dev, 1, 0);
/* free the rx buffer ring */
bcm_enet_free_rx_buf_ring(kdev, priv);
@@ -2362,7 +2362,7 @@ static int bcm_enetsw_stop(struct net_device *dev)
bcm_enet_disable_dma(priv, priv->rx_chan);
/* force reclaim of all tx buffers */
- bcm_enet_tx_reclaim(dev, 1);
+ bcm_enet_tx_reclaim(dev, 1, 0);
/* free the rx buffer ring */
bcm_enet_free_rx_buf_ring(kdev, priv);
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] bcm63xx: fix Tx cleanup when NAPI poll budget is zero
2022-07-08 8:03 ` [PATCH] bcm63xx: fix Tx cleanup when NAPI poll budget is zero Sieng-Piaw Liew
@ 2022-07-11 20:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-11 20:40 UTC (permalink / raw)
To: Sieng-Piaw Liew
Cc: davem, kuba, f.fainelli, bcm-kernel-feedback-list, netdev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 8 Jul 2022 16:03:03 +0800 you wrote:
> NAPI poll() function may be passed a budget value of zero, i.e. during
> netpoll, which isn't NAPI context.
> Therefore, napi_consume_skb() must be given budget value instead of
> !force to truly discern netpoll-like scenarios.
>
> Fixes: c63c615e22eb ("bcm63xx_enet: switch to napi_build_skb() to reuse skbuff_heads")
> Signed-off-by: Sieng-Piaw Liew <liew.s.piaw@gmail.com>
>
> [...]
Here is the summary with links:
- bcm63xx: fix Tx cleanup when NAPI poll budget is zero
https://git.kernel.org/netdev/net-next/c/10c8fd2f7a40
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] 7+ messages in thread
end of thread, other threads:[~2022-07-11 20:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-14 2:10 [PATCH] bcm63xx_enet: reuse skbuff_head Sieng Piaw Liew
2022-06-14 16:12 ` Florian Fainelli
2022-06-15 4:50 ` Jakub Kicinski
2022-06-15 6:09 ` [PATCH V2] bcm63xx_enet: switch to napi_build_skb() to reuse skbuff_heads Sieng Piaw Liew
2022-06-15 12:10 ` patchwork-bot+netdevbpf
2022-07-08 8:03 ` [PATCH] bcm63xx: fix Tx cleanup when NAPI poll budget is zero Sieng-Piaw Liew
2022-07-11 20:40 ` 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).