Skip to contentSkip to conversation

virtio_net: Warn if insufficient queue length for transmitting

PATCH In review Darius Rad 3 participants 3 messages Apr 30, 2024 – May 6, 2024

Subsystems (4)
lore
Share & tools
lore

Darius Rad

author
#0 lore raw

PATCH 1/1 virtio_net: Warn if insufficient queue length for transmitting

The transmit queue is stopped when the number of free queue entries is less than 2+MAX_SKB_FRAGS, in start_xmit(). If the queue length (QUEUE_NUM_MAX) is less than then this, transmission will immediately trigger a netdev watchdog timeout. Report this condition earlier and more directly.

---
 drivers/net/virtio_net.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/virtio_net.c +3 -0
index 115c3c5414f2..72ee8473b61c 100644
@@ -4917,6 +4917,9 @@ static int virtnet_probe(struct virtio_device *vdev)
 			set_bit(guest_offloads[i], &vi->guest_offloads);
 	vi->guest_offloads_capable = vi->guest_offloads;
 
+	if (virtqueue_get_vring_size(vi->sq->vq) < 2 + MAX_SKB_FRAGS)
+		netdev_warn_once(dev, "not enough queue entries, expect xmit timeout\n");
+
 	pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
 		 dev->name, max_queue_pairs);
 
Signature · 1 line
2.39.2
#1 lore raw
Quoted 15 lines · Darius Rad

The transmit queue is stopped when the number of free queue entries is less than 2+MAX_SKB_FRAGS, in start_xmit(). If the queue length (QUEUE_NUM_MAX) is less than then this, transmission will immediately trigger a netdev watchdog timeout. Report this condition earlier and more directly.

---
 drivers/net/virtio_net.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/virtio_net.c +0 -0
index 115c3c5414f2..72ee8473b61c 100644

drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 4922

Quoted 6 lines
drivers/net/virtio_net.c +3 -0
@@ -4917,6 +4917,9 @@ static int virtnet_probe(struct virtio_device *vdev)
 			set_bit(guest_offloads[i], &vi->guest_offloads);
 	vi->guest_offloads_capable = vi->guest_offloads;
 
+	if (virtqueue_get_vring_size(vi->sq->vq) < 2 + MAX_SKB_FRAGS)
+		netdev_warn_once(dev, "not enough queue entries, expect xmit timeout\n");
+

How about actually fixing it though? E.g. by linearizing...

It also bothers me that there's practically /proc/sys/net/core/max_skb_frags
and if that's low then things could actually work.

Finally, while originally it was just 17 typically, now it's configurable. So it's possible that you change the config to make big tcp work better and device stops working while it worked fine previously.

Quoted 5 lines
drivers/net/virtio_net.c +0 -0
 	pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
 		 dev->name, max_queue_pairs);
 
Signature · 1 line
2.39.2
#2 lore raw
Quoted 20 lines · Michael S. Tsirkin
Quoted 18 lines · Darius Rad

The transmit queue is stopped when the number of free queue entries is less than 2+MAX_SKB_FRAGS, in start_xmit(). If the queue length (QUEUE_NUM_MAX) is less than then this, transmission will immediately trigger a netdev watchdog timeout. Report this condition earlier and more directly.

---
 drivers/net/virtio_net.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/virtio_net.c +0 -0
index 115c3c5414f2..72ee8473b61c 100644
@@ -4917,6 +4917,9 @@ static int virtnet_probe(struct virtio_device *vdev)
                      set_bit(guest_offloads[i], &vi->guest_offloads);
      vi->guest_offloads_capable = vi->guest_offloads;
 
Quoted 5 lines

drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 4922

Quoted 3 lines
drivers/net/virtio_net.c +3 -0
+     if (virtqueue_get_vring_size(vi->sq->vq) < 2 + MAX_SKB_FRAGS)
+             netdev_warn_once(dev, "not enough queue entries, expect xmit timeout\n");
+

How about actually fixing it though? E.g. by linearizing...

Actually, the linearing is only needed for the case when the indirect descriptor is not supported.

Quoted 4 lines

It also bothers me that there's practically /proc/sys/net/core/max_skb_frags
and if that's low then things could actually work.

Probably not as it won't exceed MAX_SKB_FRAGS.

Quoted 4 lines

Finally, while originally it was just 17 typically, now it's configurable. So it's possible that you change the config to make big tcp

Note that virtio-net doesn't fully support big TCP.

Quoted 2 lines

work better and device stops working while it worked fine previously.

For this patch, I guess not as we had:

        if (sq->vq->num_free < 2+MAX_SKB_FRAGS)

in the tx path. So it won't even work before this patch.

Thanks

Quoted 8 lines
Quoted 7 lines
drivers/net/virtio_net.c +0 -1
      pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
               dev->name, max_queue_pairs);
 
--

2.39.2