Skip to content

Commit f5e9a22

Browse files
leitaogregkh
authored andcommitted
virtio_net: Fix napi_skb_cache_put warning
commit f8321fa upstream. 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]> [Shivani: Modified to apply on v6.6.y] Signed-off-by: Shivani Agarwal <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d8915d2 commit f5e9a22

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/virtio_net.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
21402140
return packets;
21412141
}
21422142

2143-
static void virtnet_poll_cleantx(struct receive_queue *rq)
2143+
static void virtnet_poll_cleantx(struct receive_queue *rq, int budget)
21442144
{
21452145
struct virtnet_info *vi = rq->vq->vdev->priv;
21462146
unsigned int index = vq2rxq(rq->vq);
@@ -2158,7 +2158,7 @@ static void virtnet_poll_cleantx(struct receive_queue *rq)
21582158

21592159
do {
21602160
virtqueue_disable_cb(sq->vq);
2161-
free_old_xmit_skbs(sq, true);
2161+
free_old_xmit_skbs(sq, !!budget);
21622162
} while (unlikely(!virtqueue_enable_cb_delayed(sq->vq)));
21632163

21642164
if (sq->vq->num_free >= 2 + MAX_SKB_FRAGS)
@@ -2177,7 +2177,7 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
21772177
unsigned int received;
21782178
unsigned int xdp_xmit = 0;
21792179

2180-
virtnet_poll_cleantx(rq);
2180+
virtnet_poll_cleantx(rq, budget);
21812181

21822182
received = virtnet_receive(rq, budget, &xdp_xmit);
21832183

@@ -2280,7 +2280,7 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget)
22802280
txq = netdev_get_tx_queue(vi->dev, index);
22812281
__netif_tx_lock(txq, raw_smp_processor_id());
22822282
virtqueue_disable_cb(sq->vq);
2283-
free_old_xmit_skbs(sq, true);
2283+
free_old_xmit_skbs(sq, !!budget);
22842284

22852285
if (sq->vq->num_free >= 2 + MAX_SKB_FRAGS)
22862286
netif_tx_wake_queue(txq);

0 commit comments

Comments
 (0)