From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Raphael Norwitz <raphael.s.norwitz@gmail.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] Should memory hotplug work with vhost-user backends?
Date: Tue, 28 Apr 2020 16:55:41 +0100 [thread overview]
Message-ID: <20200428155541.GI2794@work-vm> (raw)
In-Reply-To: <CAFubqFuvE9oz-N2c7Tw70sdvVDsfO7LmHD3bbRabLUpw6z5KWg@mail.gmail.com>
* Raphael Norwitz (raphael.s.norwitz@gmail.com) wrote:
> > > I've briefly looked through the libvhost-user code and the hot-add path
> > > looks safe enough to me (or at least no more broken than the regular
> > > vhost-user memory hot-add path).
> > >
> > > Can you elaborate a little more about why memory hot-add is unsafe with
> > > vhost-user device backends built with libvhost-user, as opposed to those
> > > using the raw vhost-user protocol semantics?
> >
> > The libvhost-user problem is that the library is mostly designed for a
> > single-threaded event loop that handles all virtqueue and vhost-user
> > protocol activity.
> >
> > As soon as virtqueues are handled by dedicated threads there are race
> > conditions between the virtqueue threads and the vhost-user protocol
> > thread.
> >
> > A virtqueue thread may or may not have an up-to-date view of memory
> > translation. This can result in it missing memory that is currently
> > being hotplugged and continuing to access memory that has been removed.
> >
>
> I agree - this is definitely seems like a problem if memory is being removed,
> but I don’t see how a virtqueue thread may have an outdated view of memory
> in the hot-add case.
In the vhost-user client it gets a bit tricky because the setmemtable
command doesn't give differences - it gives a whole mapping table; so
the way libvhost-user does it is to perform a whole new set of mappings.
While the qemu and kernel side doesn't see any change, the mappings do
change in the client. This probably needs a protocol improvement.
> libvhost-user now supports the REPLY_ACK feature, so that on hot-add qemu
> will wait for a response from the backend, confirming the new memory was
> successfully mapped in, before returning from vhost_user_set_mem_table(). If
> the new memory is mapped in by the backend before the ram is exposed to the
> guest, how could a virtqueue thread receive operations on missing memory?
Yeh, I think use of that new memory isn't that bad.
Dave
> > Dave might have additional comments.
> >
> > Stefan
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2020-04-28 16:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-28 14:33 [Qemu-devel] Should memory hotplug work with vhost-user backends? Raphael Norwitz
2020-04-28 15:55 ` Dr. David Alan Gilbert [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-07-02 22:08 Raphael Norwitz
2019-07-03 10:04 ` Stefan Hajnoczi
2020-04-10 0:21 ` Raphael Norwitz
2020-04-21 15:48 ` Stefan Hajnoczi
2019-07-03 18:57 ` Michael S. Tsirkin
2019-07-09 21:54 ` Raphael Norwitz
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=20200428155541.GI2794@work-vm \
--to=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=raphael.s.norwitz@gmail.com \
--cc=stefanha@redhat.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).