From: David Hildenbrand <david@redhat.com>
To: Alexander Duyck <alexander.duyck@gmail.com>, mst@redhat.com
Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v18 QEMU 3/3] virtio-balloon: Provide a interface for free page reporting
Date: Thu, 9 Apr 2020 09:44:31 +0200 [thread overview]
Message-ID: <06ac44b9-77ae-7686-8a65-7edff2cbf1b7@redhat.com> (raw)
In-Reply-To: <20200408225529.18764.44086.stgit@localhost.localdomain>
On 09.04.20 00:55, Alexander Duyck wrote:
> From: Alexander Duyck <alexander.h.duyck@linux.intel.com>
>
> Add support for what I am referring to as "free page reporting".
"Add support for "free page reporting".
> Basically the idea is to function very similar to how the balloon works
> in that we basically end up madvising the page as not being used. However
I'd get rid of one "basically".
> we don't really need to bother with any deflate type logic since the page
> will be faulted back into the guest when it is read or written to.
>
> This is meant to be a simplification of the existing balloon interface
> to use for providing hints to what memory needs to be freed. I am assuming
It's not really a simplification, it's something new. It's a new way of
letting the guest automatically report free pages to the hypervisor, so
the hypervisor can reuse them. In contrast to inflate/deflate, that's
triggered via the hypervisor explicitly.
> this is safe to do as the deflate logic does not actually appear to do very
> much other than tracking what subpages have been released and which ones
> haven't.
"I assume this is safe" does not sound very confident. Can we just drop
the last sentence?
>
> Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
> ---
> hw/virtio/virtio-balloon.c | 48 +++++++++++++++++++++++++++++++++++-
> include/hw/virtio/virtio-balloon.h | 2 +-
> 2 files changed, 47 insertions(+), 3 deletions(-)
>
> diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
> index 1c6d36a29a04..297b267198ac 100644
> --- a/hw/virtio/virtio-balloon.c
> +++ b/hw/virtio/virtio-balloon.c
> @@ -321,6 +321,42 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v,
> balloon_stats_change_timer(s, 0);
> }
>
> +static void virtio_balloon_handle_report(VirtIODevice *vdev, VirtQueue *vq)
> +{
> + VirtIOBalloon *dev = VIRTIO_BALLOON(vdev);
> + VirtQueueElement *elem;
> +
> + while ((elem = virtqueue_pop(vq, sizeof(VirtQueueElement)))) {
> + unsigned int i;
> +
> + for (i = 0; i < elem->in_num; i++) {
> + void *addr = elem->in_sg[i].iov_base;
> + size_t size = elem->in_sg[i].iov_len;
> + ram_addr_t ram_offset;
> + size_t rb_page_size;
> + RAMBlock *rb;
> +
> + if (qemu_balloon_is_inhibited() || dev->poison_val) {
> + continue;
> + }
These checks are not sufficient. See virtio_balloon_handle_output(),
where we e.g., check that somebody doesn't try to discard the bios.
Maybe we can factor our/unify the handling in both code paths.
> +
> + rb = qemu_ram_block_from_host(addr, false, &ram_offset);
> + rb_page_size = qemu_ram_pagesize(rb);
> +
> + /* For now we will simply ignore unaligned memory regions */
> + if ((ram_offset | size) & (rb_page_size - 1)) {
"!QEMU_IS_ALIGNED()" please to make this easier to read.
> + continue;
> + }
> +
> + ram_block_discard_range(rb, ram_offset, size);
> + }
> +
> + virtqueue_push(vq, elem, 0);
> + virtio_notify(vdev, vq);
> + g_free(elem);
> + }
> +}
> +
[...]
> if (virtio_has_feature(s->host_features,
> VIRTIO_BALLOON_F_FREE_PAGE_HINT)) {
> s->free_page_vq = virtio_add_queue(vdev, VIRTQUEUE_MAX_SIZE,
> @@ -940,6 +982,8 @@ static Property virtio_balloon_properties[] = {
> */
> DEFINE_PROP_BOOL("qemu-4-0-config-size", VirtIOBalloon,
> qemu_4_0_config_size, false),
> + DEFINE_PROP_BIT("unused-page-reporting", VirtIOBalloon, host_features,
"free-page-reporting"
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2020-04-09 7:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-08 22:55 [PATCH v18 QEMU 0/3] virtio-balloon: add support for providing free page reporting Alexander Duyck
2020-04-08 22:55 ` [PATCH v18 QEMU 1/3] virtio-balloon: Implement support for page poison tracking feature Alexander Duyck
2020-04-08 22:55 ` [PATCH v18 QEMU 2/3] virtio-balloon: Add support for providing free page reports to host Alexander Duyck
2020-04-09 7:35 ` David Hildenbrand
2020-04-09 14:41 ` Alexander Duyck
2020-04-09 14:43 ` David Hildenbrand
2020-04-08 22:55 ` [PATCH v18 QEMU 3/3] virtio-balloon: Provide a interface for free page reporting Alexander Duyck
2020-04-09 7:44 ` David Hildenbrand [this message]
2020-04-09 17:34 ` Alexander Duyck
2020-04-09 17:35 ` David Hildenbrand
2020-04-10 3:36 ` Alexander Duyck
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=06ac44b9-77ae-7686-8a65-7edff2cbf1b7@redhat.com \
--to=david@redhat.com \
--cc=alexander.duyck@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=virtio-dev@lists.oasis-open.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).