Skip to content

Commit f8321fa

Browse files
leitaokuba-moo
authored andcommitted
virtio_net: Fix napi_skb_cache_put warning
After the commit bdacf3e ("net: Use nested-BH locking for napi_alloc_cache.") was merged, the following warning began to appear: WARNING: CPU: 5 PID: 1 at net/core/skbuff.c:1451 napi_skb_cache_put+0x82/0x4b0 __warn+0x12f/0x340 napi_skb_cache_put+0x82/0x4b0 napi_skb_cache_put+0x82/0x4b0 report_bug+0x165/0x370 handle_bug+0x3d/0x80 exc_invalid_op+0x1a/0x50 asm_exc_invalid_op+0x1a/0x20 __free_old_xmit+0x1c8/0x510 napi_skb_cache_put+0x82/0x4b0 __free_old_xmit+0x1c8/0x510 __free_old_xmit+0x1c8/0x510 __pfx___free_old_xmit+0x10/0x10 The issue arises because virtio is assuming it's running in NAPI context even when it's not, such as in the netpoll case. To resolve this, modify virtnet_poll_tx() to only set NAPI when budget is available. Same for virtnet_poll_cleantx(), which always assumed that it was in a NAPI context. Fixes: df133f3 ("virtio_net: bulk free tx skbs") Suggested-by: Jakub Kicinski <[email protected]> Signed-off-by: Breno Leitao <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]> Reviewed-by: Heng Qi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 217b953 commit f8321fa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/virtio_net.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,7 +2750,7 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
27502750
return packets;
27512751
}
27522752

2753-
static void virtnet_poll_cleantx(struct receive_queue *rq)
2753+
static void virtnet_poll_cleantx(struct receive_queue *rq, int budget)
27542754
{
27552755
struct virtnet_info *vi = rq->vq->vdev->priv;
27562756
unsigned int index = vq2rxq(rq->vq);
@@ -2768,7 +2768,7 @@ static void virtnet_poll_cleantx(struct receive_queue *rq)
27682768

27692769
do {
27702770
virtqueue_disable_cb(sq->vq);
2771-
free_old_xmit(sq, txq, true);
2771+
free_old_xmit(sq, txq, !!budget);
27722772
} while (unlikely(!virtqueue_enable_cb_delayed(sq->vq)));
27732773

27742774
if (sq->vq->num_free >= 2 + MAX_SKB_FRAGS) {
@@ -2813,7 +2813,7 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
28132813
unsigned int xdp_xmit = 0;
28142814
bool napi_complete;
28152815

2816-
virtnet_poll_cleantx(rq);
2816+
virtnet_poll_cleantx(rq, budget);
28172817

28182818
received = virtnet_receive(rq, budget, &xdp_xmit);
28192819
rq->packets_in_napi += received;
@@ -2935,7 +2935,7 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget)
29352935
txq = netdev_get_tx_queue(vi->dev, index);
29362936
__netif_tx_lock(txq, raw_smp_processor_id());
29372937
virtqueue_disable_cb(sq->vq);
2938-
free_old_xmit(sq, txq, true);
2938+
free_old_xmit(sq, txq, !!budget);
29392939

29402940
if (sq->vq->num_free >= 2 + MAX_SKB_FRAGS) {
29412941
if (netif_tx_queue_stopped(txq)) {

0 commit comments

Comments
 (0)