All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
Subject: Re: [Devel] [PATCH vz10 4/5] fixup! vhost/vsock: re-scan TX virtqueue on device start
Date: Tue, 18 Aug 2026 18:56:54 +0200	[thread overview]
Message-ID: <10886452-9faa-493d-a26e-6f718ea76e4a@virtuozzo.com> (raw)
In-Reply-To: <20260625181637.1555685-4-eva.kurchatova@virtuozzo.com>

already applied here

The commit is pushed to "branch-rh10-6.12.0-211.16.1.12.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.16.1.12.5.vz10
------>
commit 67fdd1befc4da39f114de9a2ad4e725ea442a034
Author: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Date:   Thu Jun 4 18:46:13 2026 +0300

    vhost/vsock: re-scan TX virtqueue on device start
    
    During QEMU CPR live-update (and VHOST_RESET_OWNER in general) the guest
    keeps running while the host drops and later re-attaches vhost backends.
    If the guest adds a buffer to the TX virtqueue (guest->host) and kicks
    while the backend is temporarily NULL (between vhost_vsock_drop_backends()
    and the next vhost_vsock_start()), then the kick is delivered to the
    vhost worker, handle_tx_kick() sees a NULL backend and returns, and the
    kick signal is consumed.  The buffer is then left in the ring.
    
    Then upon device start vhost_vsock_start() only re-kicks the RX send
    worker, never the TX VQ, so the buffer is processed only if the guest
    happens to kick again.  But if the guest itself is now waiting for data
    from the host, it will never kick TX VQ again, and we end up in a
    deadlock.
    
    The deadlock is reproduced during active host->guest socat data transfer
    under multiple consecutive qemu-update's.
    
    To fix this, in vhost_vsock_start(), after kicking the RX send worker, also
    queue the TX vq poll so any buffers the guest enqueued while we were paused
    get scanned.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-131956
    https://virtuozzo.atlassian.net/browse/VSTOR-101116
    Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
    Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
    Feature: vhost-vsock: VHOST_RESET_OWNER ioctl

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 6/25/26 20:16, Eva Kurchatova wrote:
> From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> 
> During QEMU CPR live-update (and VHOST_RESET_OWNER in general) the guest
> keeps running while the host drops and later re-attaches vhost backends.
> If the guest adds a buffer to the TX virtqueue (guest->host) and kicks
> while the backend is temporarily NULL (between vhost_vsock_drop_backends()
> and the next vhost_vsock_start()), then the kick is delivered to the
> vhost worker, handle_tx_kick() sees a NULL backend and returns, and the
> kick signal is consumed.  The buffer is then left in the ring.
> 
> Then upon device start vhost_vsock_start() only re-kicks the RX send
> worker, never the TX VQ, so the buffer is processed only if the guest
> happens to kick again.  But if the guest itself is now waiting for data
> from the host, it will never kick TX VQ again, and we end up in a
> deadlock.
> 
> The deadlock is reproduced during active host->guest socat data transfer
> under multiple consecutive qemu-update's.
> 
> To fix this, in vhost_vsock_start(), after kicking the RX send worker, also
> queue the TX vq poll so any buffers the guest enqueued while we were paused
> get scanned.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-131956
> https://virtuozzo.atlassian.net/browse/VSTOR-101116
> 
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> 
> Feature: vhost-vsock: VHOST_RESET_OWNER ioctl
> ---
>  drivers/vhost/vsock.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
> index f652f47956d7..2cee40a1ca04 100644
> --- a/drivers/vhost/vsock.c
> +++ b/drivers/vhost/vsock.c
> @@ -634,6 +634,12 @@ static int vhost_vsock_start(struct vhost_vsock *vsock)
>  	/* See vhost_transport_send_pkt(); never cleared. */
>  	WRITE_ONCE(vsock->started_once, true);
>  
> +	/*
> +	 * Some packets might've also been queued in TX VQ.  Re-scan it here,
> +	 * mirroring the RX send-worker kick above.
> +	 */
> +	vhost_poll_queue(&vsock->vqs[VSOCK_VQ_TX].poll);
> +
>  	mutex_unlock(&vsock->dev.mutex);
>  	return 0;
>  


  parent reply	other threads:[~2026-08-18 16:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260625181637.1555685-1-eva.kurchatova@virtuozzo.com>
     [not found] ` <20260625181637.1555685-3-eva.kurchatova@virtuozzo.com>
2026-08-18 16:41   ` [Devel] [PATCH vz10 3/5] fixup! vhost/vsock: only refuse connection when guest has never been ready Konstantin Khorenko
2026-08-19  9:01     ` Andrey Drobyshev
2026-08-18 16:53   ` Konstantin Khorenko
     [not found] ` <20260625181637.1555685-4-eva.kurchatova@virtuozzo.com>
2026-08-18 16:56   ` Konstantin Khorenko [this message]
     [not found] ` <20260625181637.1555685-5-eva.kurchatova@virtuozzo.com>
2026-08-18 17:00   ` [Devel] [PATCH vz10 5/5] fixup! samples/bpf: fix -Wduplicate-decl-specifier and -Wmissing-declarations Konstantin Khorenko
2026-08-26 16:49     ` Konstantin Khorenko
2026-08-26 20:08     ` Eva Kurchatova (Virtuozzo)
2026-08-27 12:42       ` Konstantin Khorenko
2026-08-27 14:29         ` Eva Kurchatova (Virtuozzo)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10886452-9faa-493d-a26e-6f718ea76e4a@virtuozzo.com \
    --to=khorenko@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.