qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: David Hildenbrand <david@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v1 1/3] virtio-balloon: simplify deflate with pbp
Date: Mon, 22 Jul 2019 12:27:39 +1000	[thread overview]
Message-ID: <20190722022739.GA1426@umbus.fritz.box> (raw)
In-Reply-To: <20190719160120.26581-2-david@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2568 bytes --]

On Fri, Jul 19, 2019 at 06:01:18PM +0200, David Hildenbrand wrote:
> Let's simplify this - the case we are optimizing for is very hard to
> trigger and not worth the effort. If we're switching from inflation to
> deflation, let's reset the pbp.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/virtio/virtio-balloon.c | 24 ++++--------------------
>  1 file changed, 4 insertions(+), 20 deletions(-)
> 
> diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
> index 9de3c030bf..287d5d4c97 100644
> --- a/hw/virtio/virtio-balloon.c
> +++ b/hw/virtio/virtio-balloon.c
> @@ -121,7 +121,7 @@ static void balloon_deflate_page(VirtIOBalloon *balloon,
>      void *addr = memory_region_get_ram_ptr(mr) + offset;
>      RAMBlock *rb;
>      size_t rb_page_size;
> -    ram_addr_t ram_offset, host_page_base;
> +    ram_addr_t ram_offset;
>      void *host_addr;
>      int ret;
>  
> @@ -129,26 +129,10 @@ static void balloon_deflate_page(VirtIOBalloon *balloon,
>       * host address? */
>      rb = qemu_ram_block_from_host(addr, false, &ram_offset);
>      rb_page_size = qemu_ram_pagesize(rb);
> -    host_page_base = ram_offset & ~(rb_page_size - 1);
> -
> -    if (balloon->pbp
> -        && rb == balloon->pbp->rb
> -        && host_page_base == balloon->pbp->base) {
> -        int subpages = rb_page_size / BALLOON_PAGE_SIZE;
>  
> -        /*
> -         * This means the guest has asked to discard some of the 4kiB
> -         * subpages of a host page, but then changed its mind and
> -         * asked to keep them after all.  It's exceedingly unlikely
> -         * for a guest to do this in practice, but handle it anyway,
> -         * since getting it wrong could mean discarding memory the
> -         * guest is still using. */
> -        clear_bit((ram_offset - balloon->pbp->base) / BALLOON_PAGE_SIZE,
> -                  balloon->pbp->bitmap);
> -
> -        if (bitmap_empty(balloon->pbp->bitmap, subpages)) {
> -            virtio_balloon_reset_pbp(balloon);
> -        }
> +    if (balloon->pbp) {
> +        /* Let's play safe and always reset the pbp on deflation requests. */
> +        virtio_balloon_reset_pbp(balloon);
>      }
>  
>      host_addr = (void *)((uintptr_t)addr & ~(rb_page_size - 1));

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-07-22  3:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 16:01 [Qemu-devel] [PATCH v1 0/3] virtio-balloon: PartialBalloonedPage rework David Hildenbrand
2019-07-19 16:01 ` [Qemu-devel] [PATCH v1 1/3] virtio-balloon: simplify deflate with pbp David Hildenbrand
2019-07-22  2:27   ` David Gibson [this message]
2019-07-19 16:01 ` [Qemu-devel] [PATCH v1 2/3] virtio-balloon: Better names for offset variables in inflate/deflate code David Hildenbrand
2019-07-22  2:29   ` David Gibson
2019-07-19 16:01 ` [Qemu-devel] [PATCH v1 3/3] virtio-balloon: Rework pbp tracking data David Hildenbrand
2019-07-22  3:04   ` David Gibson
2019-07-22  7:43     ` David Hildenbrand
2019-07-22  8:14       ` Michael S. Tsirkin

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=20190722022739.GA1426@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=david@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --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).