All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Should memory hotplug work with vhost-user backends?
@ 2019-07-02 22:08 Raphael Norwitz
  2019-07-03 10:04 ` Stefan Hajnoczi
  2019-07-03 18:57 ` Michael S. Tsirkin
  0 siblings, 2 replies; 8+ messages in thread
From: Raphael Norwitz @ 2019-07-02 22:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mike Cui, Michael S. Tsirkin, Malcolm Crossley, stefanha,
	Felipe Franciosi, pbonzini, changchun.ouyang

For background I am trying to work around a ram slot limit imposed by the vhost-user protocol. We are having trouble reconciling the comment here: https://github.com/qemu/qemu/blob/master/hw/virtio/vhost-user.c#L333  that “For non-vring specific requests, like VHOST_USER_SET_MEM_TABLE., we just need to send it once the first time” and the high level implementation of memory hot-add, which calls set_mem_table every time a VM hot adds memory.

A few questions:
1.
What exactly is the check `if (vhost_user_one_time_request(msg->hdr.request) && dev->vq_index != 0)` for? In the message for commit b931bfbf042983f311b3b09894d8030b2755a638, which introduced the check, I see it says “non-vring specific messages[, which should] be sent only once” and gives VHOST_USER_SET_MEM_TABLE as an example one such message. The `vhost_user_one_time_request()` call clearly checks whether this type of message is the kind of message is supposed to be sent once of which VHOST_USER_SET_MEM_TABLE is one. Why, then, does this commit add the check if `dev->vq_index != 0`? It seems like there is a latent assumption that after the first call dev->vq_index should be set to some value greater than one, however for many cases such as vhost-user-scsi devices we can see this is clearly not the case https://github.com/qemu/qemu/blob/master/hw/scsi/vhost-user-scsi.c#L95. Is this check then ‘broken’ for such devices?

2.
If this check is indeed broken for such devices, and set_mem_table call is only supposed to be run once for such devices, is the ability to call it multiple times technically a bug for devices such as vhost-user-scsci devices? If so, this would imply that the existing ability to hot add memory to vhost-user-scsi devices is by extension technically a bug/unintended behavior. Is this the case?

Thanks,
Raphael

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [Qemu-devel] Should memory hotplug work with vhost-user backends?
@ 2020-04-28 14:33 Raphael Norwitz
  2020-04-28 15:55 ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 8+ messages in thread
From: Raphael Norwitz @ 2020-04-28 14:33 UTC (permalink / raw)
  To: stefanha, dgilbert; +Cc: qemu-devel

> > 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.

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?

> Dave might have additional comments.
>
> Stefan


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-04-28 16:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02 22:08 [Qemu-devel] Should memory hotplug work with vhost-user backends? 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
2020-04-28 14:33 Raphael Norwitz
2020-04-28 15:55 ` Dr. David Alan Gilbert

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.