Skip to contentSkip to conversation

net: lantiq_xrx200: use skb cache

PATCH Superseded Aleksander Jan Bajkowski 4 participants 5 messages Jul 12, 2022 – Jul 13, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: lantiq_xrx200: use skb cache

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. The budget parameter is added to indicate NAPI context, as a value of zero can be passed in the case of netpoll.

NAT performance results on BT Home Hub 5A (kernel 5.15.45, mtu 1500):

Fast path (Software Flow Offload):
Up Down
Before 702.4 719.3
After 707.3 739.9

Slow path:
Up Down
Before 91.8 184.1
After 92.0 185.7

---
 drivers/net/ethernet/lantiq_xrx200.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/lantiq_xrx200.c +2 -2
index 5edb68a8aab1..83e07404803f 100644
@@ -238,7 +238,7 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
 		return ret;
 	}
 
-	skb = build_skb(buf, priv->rx_skb_size);
+	skb = napi_build_skb(buf, priv->rx_skb_size);
 	skb_reserve(skb, NET_SKB_PAD);
 	skb_put(skb, len);
 
@@ -321,7 +321,7 @@ static int xrx200_tx_housekeeping(struct napi_struct *napi, int budget)
 			pkts++;
 			bytes += skb->len;
 			ch->skb[ch->tx_free] = NULL;
-			consume_skb(skb);
+			napi_consume_skb(skb, budget);
 			memset(&ch->dma.desc_base[ch->tx_free], 0,
 			       sizeof(struct ltq_dma_desc));
 			ch->tx_free++;
Signature · 1 line
2.30.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Aleksander Jan Bajkowski

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. The budget parameter is added to indicate NAPI context, as a value of zero can be passed in the case of netpoll.

NAT performance results on BT Home Hub 5A (kernel 5.15.45, mtu 1500):

Fast path (Software Flow Offload):
Up Down
Before 702.4 719.3
After 707.3 739.9

Quoted 6 lines

Slow path:
Up Down
Before 91.8 184.1
After 92.0 185.7

#2 lore raw
In reply to Aleksander Jan Bajkowski
Quoted 30 lines · Aleksander Jan Bajkowski

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. The budget parameter is added to indicate NAPI context, as a value of zero can be passed in the case of netpoll.

NAT performance results on BT Home Hub 5A (kernel 5.15.45, mtu 1500):

Fast path (Software Flow Offload):

        Up      Down
Before  702.4   719.3
After   707.3   739.9

Slow path:

        Up      Down
Before  91.8    184.1
After   92.0    185.7
---
 drivers/net/ethernet/lantiq_xrx200.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/lantiq_xrx200.c +0 -0
index 5edb68a8aab1..83e07404803f 100644

drivers/net/ethernet/lantiq_xrx200.c static int xrx200_hw_receive(struct xrx200_chan *ch) · line 241

Quoted 5 lines
drivers/net/ethernet/lantiq_xrx200.c +1 -1
@@ -238,7 +238,7 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
                return ret;
        }
 
-       skb = build_skb(buf, priv->rx_skb_size);
+       skb = napi_build_skb(buf, priv->rx_skb_size);

If you are changing this code path, what about adding proper error recovery ?

skb can be NULL at this point :/

Quoted 15 lines
drivers/net/ethernet/lantiq_xrx200.c +1 -2
        skb_reserve(skb, NET_SKB_PAD);
        skb_put(skb, len);
 
@@ -321,7 +321,7 @@ static int xrx200_tx_housekeeping(struct napi_struct *napi, int budget)
                        pkts++;
                        bytes += skb->len;
                        ch->skb[ch->tx_free] = NULL;
-                       consume_skb(skb);
+                       napi_consume_skb(skb, budget);
                        memset(&ch->dma.desc_base[ch->tx_free], 0,
                               sizeof(struct ltq_dma_desc));
                        ch->tx_free++;
--

2.30.2

#3 lore raw

Hi Eric,

Quoted 34 lines · Eric Dumazet
Quoted 33 lines · Aleksander Jan Bajkowski

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. The budget parameter is added to indicate NAPI context, as a value of zero can be passed in the case of netpoll.

NAT performance results on BT Home Hub 5A (kernel 5.15.45, mtu 1500):

Fast path (Software Flow Offload):

        Up      Down
Before  702.4   719.3
After   707.3   739.9

Slow path:

        Up      Down
Before  91.8    184.1
After   92.0    185.7
---
 drivers/net/ethernet/lantiq_xrx200.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/lantiq_xrx200.c +0 -0
index 5edb68a8aab1..83e07404803f 100644
@@ -238,7 +238,7 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
                return ret;
        }
 
Quoted 7 lines

drivers/net/ethernet/lantiq_xrx200.c static int xrx200_hw_receive(struct xrx200_chan *ch) · line 241

Quoted 2 lines
drivers/net/ethernet/lantiq_xrx200.c +1 -1
-       skb = build_skb(buf, priv->rx_skb_size);
+       skb = napi_build_skb(buf, priv->rx_skb_size);

If you are changing this code path, what about adding proper error recovery ?

skb can be NULL at this point :/

Good catch. I will try to test the fix on the device tomorrow and send the patch.

Quoted 15 lines
Quoted 13 lines
drivers/net/ethernet/lantiq_xrx200.c +1 -2
        skb_reserve(skb, NET_SKB_PAD);
        skb_put(skb, len);
 
@@ -321,7 +321,7 @@ static int xrx200_tx_housekeeping(struct napi_struct *napi, int budget)
                        pkts++;
                        bytes += skb->len;
                        ch->skb[ch->tx_free] = NULL;
-                       consume_skb(skb);
+                       napi_consume_skb(skb, budget);
                        memset(&ch->dma.desc_base[ch->tx_free], 0,
                               sizeof(struct ltq_dma_desc));
                        ch->tx_free++;
--
Quoted 2 lines

2.30.2

Best regards,
Aleksander

maintainer
#4 lore raw
Quoted 5 lines · On Wed, 13 Jul 2022 22:38:37 +0200 Aleksander Bajkowski wrote:
Quoted 3 lines

If you are changing this code path, what about adding proper error recovery ?

skb can be NULL at this point :/

Good catch. I will try to test the fix on the device tomorrow and send the patch.

Let's defer this patch until we merge the fix, otherwise we'll get a conflict. Not a big deal but easily avoidable here.