From: "Michael S. Tsirkin" <mst@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: qemu-devel@nongnu.org, Jason Wang <jasowang@redhat.com>
Subject: Re: [PATCH v1 1/2] virtio: struct VirtQueue introduce reset
Date: Sun, 29 Jan 2023 02:12:36 -0500 [thread overview]
Message-ID: <20230129020903-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20230129025150.119972-2-xuanzhuo@linux.alibaba.com>
subject seems wrong.
On Sun, Jan 29, 2023 at 10:51:49AM +0800, Xuan Zhuo wrote:
> In the current design, we stop the device from operating on the vring
> during per-queue reset by resetting the structure VirtQueue.
>
> But before the reset operation, when recycling some resources, we should
> stop referencing new vring resources. For example, when recycling
> virtio-net's asynchronous sending resources, virtio-net should be able
> to perceive that the current queue is in the per-queue reset state, and
> stop sending new packets from the tx queue.
>
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> ---
> hw/virtio/virtio.c | 15 +++++++++++++++
> include/hw/virtio/virtio.h | 1 +
> 2 files changed, 16 insertions(+)
>
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index f35178f5fc..c954f2a2b3 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -142,6 +142,8 @@ struct VirtQueue
> /* Notification enabled? */
> bool notification;
>
> + bool disabled_by_reset;
> +
> uint16_t queue_index;
>
> unsigned int inuse;
> @@ -2079,6 +2081,12 @@ void virtio_queue_reset(VirtIODevice *vdev, uint32_t queue_index)
> {
> VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
>
> + /*
> + * Mark this queue is per-queue reset status. The device should release the
> + * references of the vring, and not refer more new vring item.
items
> + */
> + vdev->vq[queue_index].disabled_by_reset = true;
> +
> if (k->queue_reset) {
> k->queue_reset(vdev, queue_index);
> }
can we set this after calling queue_reset? For symmetry with enable.
> @@ -2102,11 +2110,18 @@ void virtio_queue_enable(VirtIODevice *vdev, uint32_t queue_index)
> }
> */
>
> + vdev->vq[queue_index].disabled_by_reset = false;
> +
> if (k->queue_enable) {
> k->queue_enable(vdev, queue_index);
> }
> }
>
> +bool virtio_queue_reset_state(VirtQueue *vq)
> +{
> + return vq->disabled_by_reset;
> +}
> +
> void virtio_reset(void *opaque)
> {
> VirtIODevice *vdev = opaque;
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index 77c6c55929..00e91af7c4 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -319,6 +319,7 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val);
> void virtio_reset(void *opaque);
> void virtio_queue_reset(VirtIODevice *vdev, uint32_t queue_index);
> void virtio_queue_enable(VirtIODevice *vdev, uint32_t queue_index);
> +bool virtio_queue_reset_state(VirtQueue *vq);
> void virtio_update_irq(VirtIODevice *vdev);
> int virtio_set_features(VirtIODevice *vdev, uint64_t val);
OK I guess ... what about migration. This state won't be
set correctly will it?
>
> --
> 2.32.0.3.g01195cf9f
next prev parent reply other threads:[~2023-01-29 7:13 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-29 2:51 [PATCH v1 0/2] virtio: fix for assertion failure: virtio_net_get_subqueue(nc)->async_tx.elem failed Xuan Zhuo
2023-01-29 2:51 ` [PATCH v1 1/2] virtio: struct VirtQueue introduce reset Xuan Zhuo
2023-01-29 7:12 ` Michael S. Tsirkin [this message]
2023-01-29 7:15 ` Xuan Zhuo
2023-01-29 7:37 ` Michael S. Tsirkin
2023-01-29 7:39 ` Xuan Zhuo
2023-01-29 2:51 ` [PATCH v1 2/2] virtio-net: virtio_net_flush_tx() check for per-queue reset Xuan Zhuo
2023-01-29 6:23 ` Jason Wang
2023-01-29 7:43 ` Xuan Zhuo
2023-01-30 3:01 ` Jason Wang
2023-01-30 3:38 ` Xuan Zhuo
2023-01-30 3:53 ` Jason Wang
2023-01-30 5:50 ` Michael S. Tsirkin
2023-01-30 8:41 ` Jason Wang
2023-01-29 7:25 ` Michael S. Tsirkin
2023-01-29 7:28 ` Xuan Zhuo
2023-01-29 8:12 ` Michael S. Tsirkin
2023-01-29 8:23 ` Xuan Zhuo
2023-01-29 11:57 ` Michael S. Tsirkin
2023-01-29 12:03 ` Xuan Zhuo
2023-01-29 12:15 ` Michael S. Tsirkin
2023-01-29 12:28 ` Xuan Zhuo
2023-01-30 2:15 ` Xuan Zhuo
2023-01-30 5:32 ` Michael S. Tsirkin
2023-01-30 7:49 ` Jason Wang
2023-01-30 7:53 ` Xuan Zhuo
2023-01-30 8:40 ` Jason Wang
2023-01-30 10:24 ` Xuan Zhuo
2023-01-31 3:27 ` Jason Wang
2023-01-31 7:17 ` Xuan Zhuo
2023-01-31 7:38 ` Xuan Zhuo
2023-01-29 7:26 ` [PATCH v1 0/2] virtio: fix for assertion failure: virtio_net_get_subqueue(nc)->async_tx.elem failed Michael S. Tsirkin
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=20230129020903-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=xuanzhuo@linux.alibaba.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 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 NNTP newsgroup(s).