LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio_net: Warn if insufficient queue length for transmitting
@ 2024-04-30 19:35 Darius Rad
  2024-04-30 20:06 ` Michael S. Tsirkin
  0 siblings, 1 reply; 3+ messages in thread
From: Darius Rad @ 2024-04-30 19:35 UTC (permalink / raw
  To: Michael S. Tsirkin, Jason Wang, Xuan Zhuo, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, virtualization, netdev,
	linux-kernel

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.

Signed-off-by: Darius Rad <darius@bluespec.com>
---
 drivers/net/virtio_net.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 115c3c5414f2..72ee8473b61c 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -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);
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] virtio_net: Warn if insufficient queue length for transmitting
  2024-04-30 19:35 [PATCH] virtio_net: Warn if insufficient queue length for transmitting Darius Rad
@ 2024-04-30 20:06 ` Michael S. Tsirkin
  2024-05-06  3:24   ` Jason Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2024-04-30 20:06 UTC (permalink / raw
  To: Darius Rad
  Cc: Jason Wang, Xuan Zhuo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, virtualization, netdev, linux-kernel

On Tue, Apr 30, 2024 at 03:35:09PM -0400, Darius Rad wrote:
> 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.
> 
> Signed-off-by: Darius Rad <darius@bluespec.com>
> ---
>  drivers/net/virtio_net.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 115c3c5414f2..72ee8473b61c 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -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.


>  	pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
>  		 dev->name, max_queue_pairs);
>  
> -- 
> 2.39.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] virtio_net: Warn if insufficient queue length for transmitting
  2024-04-30 20:06 ` Michael S. Tsirkin
@ 2024-05-06  3:24   ` Jason Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2024-05-06  3:24 UTC (permalink / raw
  To: Michael S. Tsirkin
  Cc: Darius Rad, Xuan Zhuo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, virtualization, netdev, linux-kernel

On Wed, May 1, 2024 at 4:07 AM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Tue, Apr 30, 2024 at 03:35:09PM -0400, Darius Rad wrote:
> > 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.
> >
> > Signed-off-by: Darius Rad <darius@bluespec.com>
> > ---
> >  drivers/net/virtio_net.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index 115c3c5414f2..72ee8473b61c 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -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...

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

>
> 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.

>
> 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.

> 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

>
>
> >       pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
> >                dev->name, max_queue_pairs);
> >
> > --
> > 2.39.2
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-06  3:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 19:35 [PATCH] virtio_net: Warn if insufficient queue length for transmitting Darius Rad
2024-04-30 20:06 ` Michael S. Tsirkin
2024-05-06  3:24   ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).