From: David Hildenbrand <david@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: dhildenb@redhat.com, imammedo@redhat.com, ehabkost@redhat.com,
mst@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org,
qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [RFC 5/5] virtio-balloon: Safely handle BALLOON_PAGE_SIZE < host page size
Date: Wed, 17 Oct 2018 11:56:09 +0200 [thread overview]
Message-ID: <cee1e2e9-b10c-e8f3-c2a0-37555e03a6cf@redhat.com> (raw)
In-Reply-To: <20181017032859.GB30180@umbus.fritz.box>
>>>> I am pretty sure that you can create misleading warnings in case you
>>>> migrate at the wrong time. (migrate while half the 64k page is inflated,
>>>> on the new host the other part is inflated - a warning when switching to
>>>> another 64k page).
>>>
>>> Yes we can get bogus warnings across migration with this. I was
>>> considering that an acceptable price, but I'm open to better
>>> alternatives.
>>
>> Is maybe reporting a warning on a 64k host when realizing the better
>> approach than on every inflation?
>>
>> "host page size does not match virtio-balloon page size. If the guest
>> has a different page size than the host, inflating the balloon might not
>> effectively free up memory."
>
> That might work - I'll see what I can come up with. One complication
> is that theoretically at least, you can have multiple host page sizes
> (main memory in normal pages, a DIMM in hugepages). That makes the
> condition on which the warning should be issued a bit fiddly to work
> out.
I assume issuing a warning on these strange systems would not hurt after
all. ("there is a chance this might not work")
>
>> Or reporting a warning whenever changing the balloon target size.
>
> I'm not sure what you mean by this.
I mean when setting e.g. qmp_balloon() to something != 0. This avoids a
warning when a virtio-balloon device is silently created (e.g. by
libvirt?) but never used.
Checking in virtio_balloon_to_target would be sufficient I guess.
>
>>
>>>
>>>>> + free(balloon->pbp);
>>>>> + balloon->pbp = NULL;
>>>>> }
>>>>>
>>>>> - ram_block_discard_range(rb, ram_offset, rb_page_size);
>>>>> - /* We ignore errors from ram_block_discard_range(), because it has
>>>>> - * already reported them, and failing to discard a balloon page is
>>>>> - * not fatal */
>>>>> + if (!balloon->pbp) {
>>>>> + /* Starting on a new host page */
>>>>> + size_t bitlen = BITS_TO_LONGS(subpages) * sizeof(unsigned long);
>>>>> + balloon->pbp = g_malloc0(sizeof(PartiallyBalloonedPage) + bitlen);
>>>>> + balloon->pbp->rb = rb;
>>>>> + balloon->pbp->base = host_page_base;
>>>>> + }
>>>>> +
>>>>> + bitmap_set(balloon->pbp->bitmap,
>>>>> + (ram_offset - balloon->pbp->base) / BALLOON_PAGE_SIZE,
>>>>> + subpages);
>>>>> +
>>>>> + if (bitmap_full(balloon->pbp->bitmap, subpages)) {
>>>>> + /* We've accumulated a full host page, we can actually discard
>>>>> + * it now */
>>>>> +
>>>>> + ram_block_discard_range(rb, balloon->pbp->base, rb_page_size);
>>>>> + /* We ignore errors from ram_block_discard_range(), because it
>>>>> + * has already reported them, and failing to discard a balloon
>>>>> + * page is not fatal */
>>>>> +
>>>>> + free(balloon->pbp);
>>>>> + balloon->pbp = NULL;
>>>>> + }
>>>>> }
>>>> No, not a fan of this approach.
>>>
>>> I can see why, but I really can't see what else to do without breaking
>>> existing, supported, working (albeit by accident) setups.
>>
>> Is there any reason to use this more complicated "allow random freeing"
>> approach over a simplistic sequential freeing I propose? Then we can
>> simply migrate the last freed page and should be fine.
>
> Well.. your approach is probably simpler in terms of the calculations
> that need to be done, though only very slightly. I think my approach
> is conceptually clearer though, since we're explicitly checking for
> exactly the condition we need, rather than something we thing should
> match up with that condition.
I prefer to keep it simple where possible. We expect sequential freeing,
so it's easy to implement with only one additional uint64_t that can be
easily migrated. Having to use bitmaps + alloc/free is not really needed.
If you insist, at least try to get rid of the malloc to e.g. simplify
migration. (otherwise, please add freeing code on unrealize(), I guess
you are missing that right now)
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2018-10-17 9:56 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-12 3:24 [Qemu-devel] [RFC 0/5] Improve balloon handling of pagesizes other than 4kiB David Gibson
2018-10-12 3:24 ` [Qemu-devel] [RFC 1/5] virtio-balloon: Remove unnecessary MADV_WILLNEED on deflate David Gibson
2018-10-12 7:40 ` David Hildenbrand
2018-10-13 6:26 ` David Gibson
2018-10-12 17:41 ` Richard Henderson
2018-10-12 17:59 ` Eric Blake
2018-10-13 6:23 ` David Gibson
2018-10-12 18:05 ` Michael S. Tsirkin
2018-10-15 6:54 ` David Hildenbrand
2018-10-15 10:43 ` Michael S. Tsirkin
2018-10-15 11:14 ` David Hildenbrand
2018-12-04 4:26 ` David Gibson
2018-10-12 3:24 ` [Qemu-devel] [RFC 2/5] virtio-balloon: Corrections to address verification David Gibson
2018-10-12 7:44 ` David Hildenbrand
2018-10-13 6:25 ` David Gibson
2018-10-12 3:24 ` [Qemu-devel] [RFC 3/5] virtio-balloon: Rework ballon_page() interface David Gibson
2018-10-12 7:46 ` David Hildenbrand
2018-10-13 6:29 ` David Gibson
2018-10-12 3:24 ` [Qemu-devel] [RFC 4/5] virtio-balloon: Use ram_block_discard_range() instead of raw madvise() David Gibson
2018-10-12 3:24 ` [Qemu-devel] [RFC 5/5] virtio-balloon: Safely handle BALLOON_PAGE_SIZE < host page size David Gibson
2018-10-12 8:06 ` David Hildenbrand
2018-10-13 6:40 ` David Gibson
2018-10-15 7:08 ` David Hildenbrand
2018-10-17 3:28 ` David Gibson
2018-10-17 9:56 ` David Hildenbrand [this message]
2018-10-23 8:02 ` David Gibson
2018-10-23 15:13 ` David Hildenbrand
2018-10-12 8:32 ` David Hildenbrand
2018-10-13 6:41 ` David Gibson
2018-10-12 17:26 ` [Qemu-devel] [RFC 0/5] Improve balloon handling of pagesizes other than 4kiB Michael S. Tsirkin
2018-10-17 3:31 ` David Gibson
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=cee1e2e9-b10c-e8f3-c2a0-37555e03a6cf@redhat.com \
--to=david@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=dhildenb@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).