virtio_net: suppress cpu stall when free_unused_bufs
authorWenliang Wang <wangwenliang.1995@bytedance.com>
Thu, 4 May 2023 02:27:06 +0000 (10:27 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 May 2023 08:30:28 +0000 (09:30 +0100)
For multi-queue and large ring-size use case, the following error
occurred when free_unused_bufs:
rcu: INFO: rcu_sched self-detected stall on CPU.

Fixes: 986a4f4d452d ("virtio_net: multiqueue support")
Signed-off-by: Wenliang Wang <wangwenliang.1995@bytedance.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/virtio_net.c

index 8d80385..a12ae26 100644 (file)
@@ -3560,12 +3560,14 @@ static void free_unused_bufs(struct virtnet_info *vi)
                struct virtqueue *vq = vi->sq[i].vq;
                while ((buf = virtqueue_detach_unused_buf(vq)) != NULL)
                        virtnet_sq_free_unused_buf(vq, buf);
+               cond_resched();
        }
 
        for (i = 0; i < vi->max_queue_pairs; i++) {
                struct virtqueue *vq = vi->rq[i].vq;
                while ((buf = virtqueue_detach_unused_buf(vq)) != NULL)
                        virtnet_rq_free_unused_buf(vq, buf);
+               cond_resched();
        }
 }