qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v1 1/3] virtio-balloon: simplify deflate with pb


From: David Gibson
Subject: Re: [Qemu-devel] [PATCH v1 1/3] virtio-balloon: simplify deflate with pbp
Date: Mon, 22 Jul 2019 12:27:39 +1000
User-agent: Mutt/1.12.0 (2019-05-25)

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 <address@hidden>

Acked-by: David Gibson <address@hidden>

> ---
>  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: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]