Re: [PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-04 Thread Michael S. Tsirkin
On Fri, Jul 05, 2024 at 02:21:35AM +, Yang Dongshan wrote: > > virtqueue_get_avail_bytes would always return the opaque. > Then the condition will change from: > > static int virtio_net_has_buffers(VirtIONetQueue *q, int bufsize) > { > if (virtio_queue_empty(q->rx_vq) || > (n->

Re: [PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-04 Thread Yang Dongshan
> virtqueue_get_avail_bytes would always return the opaque. Then the condition will change from: static int virtio_net_has_buffers(VirtIONetQueue *q, int bufsize) { if (virtio_queue_empty(q->rx_vq) || (n->mergeable_rx_bufs && !virtqueue_avail_bytes(q->rx_vq, bufsize, 0))

Re: [PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-04 Thread Michael S. Tsirkin
On Thu, Jul 04, 2024 at 10:20:15AM +, Yang Dongshan wrote: > Hi, Michael > > > My suggestion: > > > > > > change virtqueue_get_avail_bytes to return the shadow > > in an opaque unsigned value. > > > > > > add virtqueue_poll that gets this opaque and tells us whether any new > > buffers bec

Re: [PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-04 Thread Yang Dongshan
Hi, Michael > My suggestion: > > > change virtqueue_get_avail_bytes to return the shadow > in an opaque unsigned value. > > > add virtqueue_poll that gets this opaque and tells us whether any new > buffers became available in the queue since that value> > was returned. > accordingly, virtio

Re: [PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-02 Thread Yang Dongshan
> This answer does not make sense from API POV. The core logic of function virtio_queue_set_notification_and_check() actually is a copy of function vhost_enable_notify() from vhost.c in kernel. > > > +bool virtio_queue_set_notification_and_check(VirtQueue *vq, int enable) > > > +{ > > > + uint16

Re: [PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-02 Thread Michael S. Tsirkin
On Tue, Jul 02, 2024 at 07:45:31AM +0800, Yang Dongshan wrote: > > what does "changed" mean here? changed compared to what? > For a split queue, if the shadow_avail_idx synced from avail ring idx > by vring_avail_idx(vq) last time doesn't equal the current value of avail ring > idx. > > vq->shadow

Re: [PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-01 Thread Yang Dongshan
> what does "changed" mean here? changed compared to what? For a split queue, if the shadow_avail_idx synced from avail ring idx by *vring_avail_idx(vq) last time doesn't equal the current value of avail ring idx.* *vq->shadow_avail_idx **!= vring_avail_idx(vq);* For packed queue, the logic is si

Re: [PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-01 Thread Michael S. Tsirkin
On Tue, Jul 02, 2024 at 01:18:15AM +0800, Yang Dongshan wrote: > > Please document what this does. > okay, i will. > > > So this will return false if ring has any available buffers? > > Equivalent to: > >  > > bool virtio_queue_set_notification_and_check(VirtQueue *vq, int enable) > > { > >       

Re: [PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-01 Thread Yang Dongshan
> Please document what this does. okay, i will. > So this will return false if ring has any available buffers? > Equivalent to: > > bool virtio_queue_set_notification_and_check(VirtQueue *vq, int enable) > { >virtio_queue_packed_set_notification(vq, enable); > return virtio_queue_e

Re: [PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-01 Thread Michael S. Tsirkin
On Mon, Jul 01, 2024 at 10:00:17PM +0800, Wencheng Yang wrote: > From: thomas > > Patch 06b12970174 ("virtio-net: fix network stall under load") > added double-check to test whether the available buffer size > can satisfy the request or not, in case the guest has added > some buffers to the avail

[PATCH v7] virtio-net: Fix network stall at the host side waiting for kick

2024-07-01 Thread Wencheng Yang
From: thomas Patch 06b12970174 ("virtio-net: fix network stall under load") added double-check to test whether the available buffer size can satisfy the request or not, in case the guest has added some buffers to the avail ring simultaneously after the first check. It will be lucky if the availab