public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [Query] [GUEST PAGE HINTING] How to handle virtqueue_kick from the guest in QEMU
@ 2017-08-11 21:00 Nitesh Narayan Lal
  2017-08-17 10:38 ` David Hildenbrand
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nitesh Narayan Lal @ 2017-08-11 21:00 UTC (permalink / raw)
  To: kvm; +Cc: mst, pagupta, wei.w.wang, yang.zhang.wz, riel, david


[-- Attachment #1.1: Type: text/plain, Size: 1381 bytes --]

Hi,

In my project of "Guest Page Hinting"[1], I have a list of pages which
are supposed to be passed to the host. Now I am trying to figure out the
changes which I should make in QEMU in order to pass this request to the
host.

Unlike virtio balloon where the request to deflate/inflate is derived
from the host, in my case, I need to figure out how the request which is
generated in the guest could be received in QEMU. One way to go about
this is to have my own function pointer pointing a to a function
qemu_page_hinting() in virtio-balloon.c under QEMU. Now the part where I
am not sure is how exactly I will ensure that when virtqueue_kick
arrives in QEMU this function is invoked. (I am planning to use the same
deflate_vq for my use-case).

Another way could be to make changes in the existing
"virtio_balloon_handle_output" and may add another flag in the virtqueue
structure using which I could distinguish if it's a guest page hinting
request. But even in this case, I am not sure how will it work because
from what I understood when a user sends a deflate request then this
function gets invoked and after all the processing it notifies the
guest. (Which is opposite of what I am trying to achieve).

Any suggestion what should be the right way to go forward?

[1] https://www.spinics.net/lists/kvm/msg153666.html

-- 

Regards
Nitesh


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [Query] [GUEST PAGE HINTING] How to handle virtqueue_kick from the guest in QEMU
  2017-08-11 21:00 [Query] [GUEST PAGE HINTING] How to handle virtqueue_kick from the guest in QEMU Nitesh Narayan Lal
@ 2017-08-17 10:38 ` David Hildenbrand
  2017-08-17 15:48 ` Michael S. Tsirkin
  2017-08-17 16:53 ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2017-08-17 10:38 UTC (permalink / raw)
  To: Nitesh Narayan Lal, kvm; +Cc: mst, pagupta, wei.w.wang, yang.zhang.wz, riel

On 11.08.2017 23:00, Nitesh Narayan Lal wrote:
> Hi,
> 
> In my project of "Guest Page Hinting"[1], I have a list of pages which
> are supposed to be passed to the host. Now I am trying to figure out the
> changes which I should make in QEMU in order to pass this request to the
> host.

Will you only inform about "this page is free" or also about "I will
reuse this page" if you agree? (relevant because of
VIRTIO_BALLOON_F_MUST_TELL_HOST)

> 
> Unlike virtio balloon where the request to deflate/inflate is derived
> from the host, in my case, I need to figure out how the request which is
> generated in the guest could be received in QEMU. One way to go about
> this is to have my own function pointer pointing a to a function
> qemu_page_hinting() in virtio-balloon.c under QEMU. Now the part where I
> am not sure is how exactly I will ensure that when virtqueue_kick
> arrives in QEMU this function is invoked. (I am planning to use the same
> deflate_vq for my use-case).

Requests to inflate/deflate are always communicated via config updates.

The inflate queue is always guest->host controlled: tell_host() waits
until control is handed back.

On the QEMU side, virtio_balloon_handle_output() will simply
MADV_DONTNEED, independent of any requested config changes if I am not
mistaking.

> 
> Another way could be to make changes in the existing
> "virtio_balloon_handle_output" and may add another flag in the virtqueue
> structure using which I could distinguish if it's a guest page hinting
> request. But even in this case, I am not sure how will it work because
> from what I understood when a user sends a deflate request then this
> function gets invoked and after all the processing it notifies the
> guest. (Which is opposite of what I am trying to achieve).

Can you elaborate what exactly the problem is with
virtio_balloon_handle_output()?

>From what I recap:

1. the queue is completely guest->host controlled
2. after every inflate/deflate request, control is given back to the guest

> 
> Any suggestion what should be the right way to go forward?
> 
> [1] https://www.spinics.net/lists/kvm/msg153666.html
> 


-- 

Thanks,

David

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

* Re: [Query] [GUEST PAGE HINTING] How to handle virtqueue_kick from the guest in QEMU
  2017-08-11 21:00 [Query] [GUEST PAGE HINTING] How to handle virtqueue_kick from the guest in QEMU Nitesh Narayan Lal
  2017-08-17 10:38 ` David Hildenbrand
@ 2017-08-17 15:48 ` Michael S. Tsirkin
  2017-08-17 16:53 ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2017-08-17 15:48 UTC (permalink / raw)
  To: Nitesh Narayan Lal; +Cc: kvm, pagupta, wei.w.wang, yang.zhang.wz, riel, david

On Fri, Aug 11, 2017 at 05:00:15PM -0400, Nitesh Narayan Lal wrote:
> Hi,
> 
> In my project of "Guest Page Hinting"[1], I have a list of pages which
> are supposed to be passed to the host. Now I am trying to figure out the
> changes which I should make in QEMU in order to pass this request to the
> host.
> 
> Unlike virtio balloon where the request to deflate/inflate is derived
> from the host, in my case, I need to figure out how the request which is
> generated in the guest could be received in QEMU. One way to go about
> this is to have my own function pointer pointing a to a function
> qemu_page_hinting() in virtio-balloon.c under QEMU. Now the part where I
> am not sure is how exactly I will ensure that when virtqueue_kick
> arrives in QEMU this function is invoked. (I am planning to use the same
> deflate_vq for my use-case).
>
> Another way could be to make changes in the existing
> "virtio_balloon_handle_output" and may add another flag in the virtqueue
> structure using which I could distinguish if it's a guest page hinting
> request. But even in this case, I am not sure how will it work because
> from what I understood when a user sends a deflate request then this
> function gets invoked and after all the processing it notifies the
> guest. (Which is opposite of what I am trying to achieve).
> 
> Any suggestion what should be the right way to go forward?
> 
> [1] https://www.spinics.net/lists/kvm/msg153666.html


I would just create a new vq for this, at least initially.


> -- 
> 
> Regards
> Nitesh
> 

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

* Re: [Query] [GUEST PAGE HINTING] How to handle virtqueue_kick from the guest in QEMU
  2017-08-11 21:00 [Query] [GUEST PAGE HINTING] How to handle virtqueue_kick from the guest in QEMU Nitesh Narayan Lal
  2017-08-17 10:38 ` David Hildenbrand
  2017-08-17 15:48 ` Michael S. Tsirkin
@ 2017-08-17 16:53 ` Paolo Bonzini
  2017-08-18  1:32   ` Michael S. Tsirkin
  2 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2017-08-17 16:53 UTC (permalink / raw)
  To: Nitesh Narayan Lal, kvm
  Cc: mst, pagupta, wei.w.wang, yang.zhang.wz, riel, david

On 11/08/2017 23:00, Nitesh Narayan Lal wrote:
> One way to go about
> this is to have my own function pointer pointing a to a function
> qemu_page_hinting() in virtio-balloon.c under QEMU. Now the part where I
> am not sure is how exactly I will ensure that when virtqueue_kick
> arrives in QEMU this function is invoked. (I am planning to use the same
> deflate_vq for my use-case).

You can use a separate virtq as Michael mentioned.

Another possibility is to extend virtio-balloon to support 64-bit values
in the virtqueues.  Then when shifting PFNs right you have bits 52-63
free, and you can put flags in there (e.g. bit 52=0 means deflate, bit
52=1 means page hint).

Of course, if your action is going to be MADV_DONTNEED, you don't need
to do anything special.

Paolo

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

* Re: [Query] [GUEST PAGE HINTING] How to handle virtqueue_kick from the guest in QEMU
  2017-08-17 16:53 ` Paolo Bonzini
@ 2017-08-18  1:32   ` Michael S. Tsirkin
  0 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2017-08-18  1:32 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Nitesh Narayan Lal, kvm, pagupta, wei.w.wang, yang.zhang.wz, riel,
	david

On Thu, Aug 17, 2017 at 06:53:31PM +0200, Paolo Bonzini wrote:
> On 11/08/2017 23:00, Nitesh Narayan Lal wrote:
> > One way to go about
> > this is to have my own function pointer pointing a to a function
> > qemu_page_hinting() in virtio-balloon.c under QEMU. Now the part where I
> > am not sure is how exactly I will ensure that when virtqueue_kick
> > arrives in QEMU this function is invoked. (I am planning to use the same
> > deflate_vq for my use-case).
> 
> You can use a separate virtq as Michael mentioned.
> 
> Another possibility is to extend virtio-balloon to support 64-bit values
> in the virtqueues.  Then when shifting PFNs right you have bits 52-63
> free, and you can put flags in there (e.g. bit 52=0 means deflate, bit
> 52=1 means page hint).
>
> Of course, if your action is going to be MADV_DONTNEED, you don't need
> to do anything special.
> 
> Paolo

Forgot to say: when you discuss virtio host/guest interface changes,
please copy virtio-dev@lists.oasis-open.org. (Subscriber only, sorry
about that).

-- 
MST

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

end of thread, other threads:[~2017-08-18  1:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-11 21:00 [Query] [GUEST PAGE HINTING] How to handle virtqueue_kick from the guest in QEMU Nitesh Narayan Lal
2017-08-17 10:38 ` David Hildenbrand
2017-08-17 15:48 ` Michael S. Tsirkin
2017-08-17 16:53 ` Paolo Bonzini
2017-08-18  1:32   ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox