From: Jason Wang <jasowang@redhat.com>
To: Zhu Lingshan <lingshan.zhu@intel.com>
Cc: mst@redhat.com, eperezma@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH V2] vhost_vdpa: no need to fetch vring base when poweroff
Date: Tue, 11 Jul 2023 10:50:13 +0800 [thread overview]
Message-ID: <CACGkMEsNE995Z-TE8wiPc3TwLd3N4Rd+hGMGNfR-d1tFdwOM-Q@mail.gmail.com> (raw)
In-Reply-To: <20230710165333.17506-1-lingshan.zhu@intel.com>
On Mon, Jul 10, 2023 at 4:53 PM Zhu Lingshan <lingshan.zhu@intel.com> wrote:
>
> In the poweroff routine, no need to fetch last available index.
>
This is because there's no concept of shutdown in the vhost layer, it
only knows start and stop.
> This commit also provides a better debug message in the vhost
> caller vhost_virtqueue_stop,
A separate patch is better.
> because if vhost does not fetch
> the last avail idx successfully, maybe the device does not
> suspend, vhost will sync last avail idx to vring used idx as a
> work around, not a failure.
This only happens if we return a negative value?
>
> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
> ---
> hw/virtio/vhost-vdpa.c | 10 ++++++++++
> hw/virtio/vhost.c | 2 +-
> 2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index 3c575a9a6e..10b445f64e 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -26,6 +26,7 @@
> #include "cpu.h"
> #include "trace.h"
> #include "qapi/error.h"
> +#include "sysemu/runstate.h"
>
> /*
> * Return one past the end of the end of section. Be careful with uint64_t
> @@ -1391,6 +1392,15 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
> struct vhost_vdpa *v = dev->opaque;
> int ret;
>
> + if (runstate_check(RUN_STATE_SHUTDOWN)) {
> + /*
> + * Some devices do not support this call properly,
> + * and we don't need to retrieve the indexes
> + * if it is shutting down
> + */
> + return 0;
Checking runstate in the vhost code seems like a layer violation.
What happens without this patch?
Thanks
> + }
> +
> if (v->shadow_vqs_enabled) {
> ring->num = virtio_queue_get_last_avail_idx(dev->vdev, ring->index);
> return 0;
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 82394331bf..7dd90cff3a 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1262,7 +1262,7 @@ void vhost_virtqueue_stop(struct vhost_dev *dev,
>
> r = dev->vhost_ops->vhost_get_vring_base(dev, &state);
> if (r < 0) {
> - VHOST_OPS_DEBUG(r, "vhost VQ %u ring restore failed: %d", idx, r);
> + VHOST_OPS_DEBUG(r, "sync last avail idx to the guest used idx for vhost VQ %u", idx);
> /* Connection to the backend is broken, so let's sync internal
> * last avail idx to the device used idx.
> */
> --
> 2.39.3
>
next prev parent reply other threads:[~2023-07-11 2:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 16:53 [PATCH V2] vhost_vdpa: no need to fetch vring base when poweroff Zhu Lingshan
2023-07-10 9:21 ` Eugenio Perez Martin
2023-07-11 2:50 ` Jason Wang [this message]
2023-07-11 4:09 ` Zhu, Lingshan
2023-07-11 7:05 ` Jason Wang
2023-07-11 7:24 ` Eugenio Perez Martin
2023-07-11 7:34 ` Jason Wang
2023-07-12 6:54 ` Zhu, Lingshan
2023-07-12 7:22 ` Jason Wang
2023-07-12 10:14 ` Zhu, Lingshan
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=CACGkMEsNE995Z-TE8wiPc3TwLd3N4Rd+hGMGNfR-d1tFdwOM-Q@mail.gmail.com \
--to=jasowang@redhat.com \
--cc=eperezma@redhat.com \
--cc=lingshan.zhu@intel.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).