qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, qemu-devel@nongnu.org
Cc: David Gibson <dgibson@redhat.com>, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] virtio-balloon: free pbp more aggressively
Date: Thu, 25 Jul 2019 14:13:47 +0200	[thread overview]
Message-ID: <57f5849f-6340-781d-7475-46784351fabb@redhat.com> (raw)
In-Reply-To: <20190725115914.26983-1-mst@redhat.com>

> -static void virtio_balloon_pbp_free(PartiallyBalloonedPage *pbp)
> +static void virtio_balloon_pbp_free(PartiallyBalloonedPage **pbp)
>  {
> -    if (!pbp) {
> +    if (!*pbp) {
>          return;
>      }
> -    g_free(pbp->bitmap);
> -    g_free(pbp);
> +    g_free(*pbp->bitmap);

This has to be

g_free((*pbp)->bitmap);

to compile.

> +    g_free(*pbp);
> +    *pbp = NULL;
>  }
>  
>  static PartiallyBalloonedPage *virtio_balloon_pbp_alloc(ram_addr_t base_gpa,
> @@ -108,8 +109,7 @@ static void balloon_inflate_page(VirtIOBalloon *balloon,
>          /* We've partially ballooned part of a host page, but now
>           * we're trying to balloon part of a different one.  Too hard,
>           * give up on the old partial page */
> -        virtio_balloon_pbp_free(*pbp);
> -        *pbp = NULL;
> +        virtio_balloon_pbp_free(pbp);
>      }
>  
>      if (!*pbp) {
> @@ -127,8 +127,7 @@ static void balloon_inflate_page(VirtIOBalloon *balloon,
>          /* We ignore errors from ram_block_discard_range(), because it
>           * has already reported them, and failing to discard a balloon
>           * page is not fatal */
> -        virtio_balloon_pbp_free(*pbp);
> -        *pbp = NULL;
> +        virtio_balloon_pbp_free(pbp);
>      }
>  }
>  
> @@ -379,9 +378,8 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)
>          virtqueue_push(vq, elem, offset);
>          virtio_notify(vdev, vq);
>          g_free(elem);
> +        virtio_balloon_pbp_free(&pbp);

You could move the "PartiallyBalloonedPage *pbp = NULL;" now into the loop.

>      }
> -
> -    virtio_balloon_pbp_free(pbp);
>  }
>  
>  static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq)
> 

Gave it a quick test with a hugepage backing on x86 - still works. Would
be good if somebody could test with 64k PPC guest.

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David / dhildenb


      reply	other threads:[~2019-07-25 12:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-25 11:59 [Qemu-devel] [PATCH] virtio-balloon: free pbp more aggressively Michael S. Tsirkin
2019-07-25 12:13 ` David Hildenbrand [this message]

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=57f5849f-6340-781d-7475-46784351fabb@redhat.com \
    --to=david@redhat.com \
    --cc=dgibson@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.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).