virtio_net: bulk free tx skbs
Subsystems (4)
Michael S. Tsirkin
maintainerPATCH v2 1/1 virtio_net: bulk free tx skbs
Use napi_consume_skb() to get bulk free. Note that napi_consume_skb is safe to call in a non-napi context as long as the napi_budget flag is correct.
---
Changes from v1:
rebase on master.
lightly tested on developer's box.
drivers/net/virtio_net.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/virtio_net.c +6 -6
@@ -1330,7 +1330,7 @@ static int virtnet_receive(struct receive_queue *rq, int budget,return stats.packets; } -static void free_old_xmit_skbs (struct send_queue *sq) +static void free_old_xmit_skbs (struct send_queue *sq,bool in_napi) {struct sk_buff *skb;unsigned int len;
@@ -1343,7 +1343,7 @@ static void free_old_xmit_skbs(struct send_queue *sq) bytes += skb->len; packets++; -dev_consume_skb_any (skb); +napi_consume_skb (skb, in_napi); }/* Avoid overhead when no packets have been processed
@@ -1369,7 +1369,7 @@ static void virtnet_poll_cleantx(struct receive_queue *rq)return ;if (__netif_tx_trylock (txq)) { -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, true);__netif_tx_unlock (txq); }
@@ -1445,7 +1445,7 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget)struct netdev_queue *txq =netdev_get_tx_queue (vi->dev,vq2txq (sq->vq));__netif_tx_lock (txq,raw_smp_processor_id ()); -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, true);__netif_tx_unlock (txq);virtqueue_napi_complete (napi, sq->vq,0 );
@@ -1514,7 +1514,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)bool use_napi = sq->napi.weight;/* Free up any pending old buffers before queueing new ones. */ -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, false);if (use_napi && kick)virtqueue_enable_cb_delayed (sq->vq);
@@ -1557,7 +1557,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)if (!use_napi &&unlikely (!virtqueue_enable_cb_delayed (sq->vq))) {/* More just got used, free them then recheck. */ -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, false);if (sq->vq->num_free >=2 +MAX_SKB_FRAGS ) {netif_start_subqueue (dev, qnum);virtqueue_disable_cb (sq->vq);
Signature · 1 line
MST
Quoted 7 lines · Michael S. Tsirkin
Use
napi_consume_skb()to get bulk free. Note thatnapi_consume_skbis safe to call in a non-napi context as long as thenapi_budgetflag is correct.Signed-off-by Michael S. Tsirkin <[email protected]>---
Quoted 7 lines
Changes from v1:
rebase on master.lightly tested on developer's box.
drivers/net/virtio_net.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Quoted 51 lines
drivers/net/virtio_net.c +5
-5@@ -1330,7 +1330,7 @@ static int virtnet_receive(struct receive_queue *rq, int budget,return stats.packets; } -static void free_old_xmit_skbs (struct send_queue *sq) +static void free_old_xmit_skbs (struct send_queue *sq,bool in_napi) {struct sk_buff *skb;unsigned int len;@@ -1343,7 +1343,7 @@ static void free_old_xmit_skbs(struct send_queue *sq) bytes += skb->len; packets++; -dev_consume_skb_any (skb); +napi_consume_skb (skb, in_napi); }/* Avoid overhead when no packets have been processed @@ -1369,7 +1369,7 @@ static void virtnet_poll_cleantx(struct receive_queue *rq)return ;if (__netif_tx_trylock (txq)) { -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, true);__netif_tx_unlock (txq); }@@ -1445,7 +1445,7 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget)struct netdev_queue *txq =netdev_get_tx_queue (vi->dev,vq2txq (sq->vq));__netif_tx_lock (txq,raw_smp_processor_id ()); -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, true);__netif_tx_unlock (txq);virtqueue_napi_complete (napi, sq->vq,0 );@@ -1514,7 +1514,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)bool use_napi = sq->napi.weight;/* Free up any pending old buffers before queueing new ones. */ -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, false);if (use_napi && kick)virtqueue_enable_cb_delayed (sq->vq);
drivers/net/virtio_net.c static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) · line 1563
Quoted 8 lines
drivers/net/virtio_net.c +1
-1@@ -1557,7 +1557,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)if (!use_napi &&unlikely (!virtqueue_enable_cb_delayed (sq->vq))) {/* More just got used, free them then recheck. */ -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, false);if (sq->vq->num_free >=2 +MAX_SKB_FRAGS ) {netif_start_subqueue (dev, qnum);virtqueue_disable_cb (sq->vq);
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 7 lines · Michael S. Tsirkin
Use
napi_consume_skb()to get bulk free. Note thatnapi_consume_skbis safe to call in a non-napi context as long as thenapi_budgetflag is correct.Signed-off-by Michael S. Tsirkin <[email protected]>---
Quoted 7 lines
Changes from v1:
rebase on master.lightly tested on developer's box.
drivers/net/virtio_net.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Quoted 59 lines
drivers/net/virtio_net.c +6
-6@@ -1330,7 +1330,7 @@ static int virtnet_receive(struct receive_queue *rq, int budget,return stats.packets; } -static void free_old_xmit_skbs (struct send_queue *sq) +static void free_old_xmit_skbs (struct send_queue *sq,bool in_napi) {struct sk_buff *skb;unsigned int len;@@ -1343,7 +1343,7 @@ static void free_old_xmit_skbs(struct send_queue *sq) bytes += skb->len; packets++; -dev_consume_skb_any (skb); +napi_consume_skb (skb, in_napi); }/* Avoid overhead when no packets have been processed @@ -1369,7 +1369,7 @@ static void virtnet_poll_cleantx(struct receive_queue *rq)return ;if (__netif_tx_trylock (txq)) { -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, true);__netif_tx_unlock (txq); }@@ -1445,7 +1445,7 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget)struct netdev_queue *txq =netdev_get_tx_queue (vi->dev,vq2txq (sq->vq));__netif_tx_lock (txq,raw_smp_processor_id ()); -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, true);__netif_tx_unlock (txq);virtqueue_napi_complete (napi, sq->vq,0 );@@ -1514,7 +1514,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)bool use_napi = sq->napi.weight;/* Free up any pending old buffers before queueing new ones. */ -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, false);if (use_napi && kick)virtqueue_enable_cb_delayed (sq->vq);@@ -1557,7 +1557,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)if (!use_napi &&unlikely (!virtqueue_enable_cb_delayed (sq->vq))) {/* More just got used, free them then recheck. */ -free_old_xmit_skbs (sq); +free_old_xmit_skbs (sq, false);if (sq->vq->num_free >=2 +MAX_SKB_FRAGS ) {netif_start_subqueue (dev, qnum);virtqueue_disable_cb (sq->vq);
From: "Michael S. Tsirkin" <[email protected]>
Date: Thu, 17 Jan 2019 23:20:07 -0500
Quoted 5 lines
Use
napi_consume_skb()to get bulk free. Note thatnapi_consume_skbis safe to call in a non-napi context as long as thenapi_budgetflag is correct.Signed-off-by Michael S. Tsirkin <[email protected]>
Applied, thanks.
From: "Michael S. Tsirkin" <[email protected]>
Date: Thu, 17 Jan 2019 23:20:07 -0500
Quoted 5 lines
Use
napi_consume_skb()to get bulk free. Note thatnapi_consume_skbis safe to call in a non-napi context as long as thenapi_budgetflag is correct.Signed-off-by Michael S. Tsirkin <[email protected]>
Applied, thanks.