[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <286AC319A985734F985F78AFA26841F73DF6F195@shsmsx102.ccr.corp.intel.com>
Date: Thu, 14 Feb 2019 09:08:48 +0000
From: "Wang, Wei W" <wei.w.wang@...el.com>
To: 'David Hildenbrand' <david@...hat.com>,
Nitesh Narayan Lal <nitesh@...hat.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"lcapitulino@...hat.com" <lcapitulino@...hat.com>,
"pagupta@...hat.com" <pagupta@...hat.com>,
"yang.zhang.wz@...il.com" <yang.zhang.wz@...il.com>,
"riel@...riel.com" <riel@...riel.com>,
"mst@...hat.com" <mst@...hat.com>,
"dodgen@...gle.com" <dodgen@...gle.com>,
"konrad.wilk@...cle.com" <konrad.wilk@...cle.com>,
"dhildenb@...hat.com" <dhildenb@...hat.com>,
"aarcange@...hat.com" <aarcange@...hat.com>
Subject: RE: [RFC][Patch v8 0/7] KVM: Guest Free Page Hinting
On Wednesday, February 13, 2019 5:19 PM, David Hildenbrand wrote:
> If you have to resize/alloc/coordinate who will report, you will need locking.
> Especially, I doubt that there is an atomic xbitmap (prove me wrong :) ).
Yes, we need change xbitmap to support it.
Just thought of another option, which would be better:
- xb_preload in prepare_alloc_pages to pre-allocate the bitmap memory;
- xb_set/clear the bit under the zone->lock, i.e. in rmqueue and free_one_page
So we use the existing zone->lock to guarantee that the xb ops
will not be concurrently called to race on the same bitmap.
And we don't add any new locks to generate new doubts.
Also, we can probably remove the arch_alloc/free_page part.
For the first step, we could optimize VIRTIO_BALLOON_F_FREE_PAGE_HINT for the live migration optimization:
- just replace alloc_pages(VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG,
VIRTIO_BALLOON_FREE_PAGE_ORDER)
with get_free_page_hints()
get_free_page_hints() was designed to clear the bit, and need put_free_page_hints() to set it later after host finishes madvise. For the live migration usage, as host doesn't free the backing host pages, so we can give get_free_page_hints a parameter option to not clear the bit for this usage. It will be simpler and faster.
I think get_free_page_hints() to read hints via bitmaps should be much faster than that allocation function, which takes around 15us to get a 4MB block. Another big bonus is that we don't need free_pages() to return all the pages back to buddy (it's a quite expensive operation too) when migration is done.
For the second step, we can improve ballooning, e.g. a new feature VIRTIO_BALLOON_F_ADVANCED_BALLOON to use the same get_free_page_hints() and another put_free_page_hints(), along with the virtio-balloon's report_vq and ack_vq to wait for the host's ack before making the free page ready.
(I think waiting for the host ack is the overhead that the guest has to suffer for enabling memory overcommitment, and even with this v8 patch series it also needs to do that. The optimization method was described yesterday)
> Yes, but as I mentioned this has other drawbacks. Relying on a a guest to free
> up memory when you really need it is not going to work.
why not working? Host can ask at any time (including when not urgently need it) depending on the admin's configuration.
>It might work for
> some scenarios but should not dictate the design. It is a good start though if
> it makes things easier.
> Enabling/disabling free page hintning by the hypervisor via some
> mechanism is on the other hand a good idea. "I have plenty of free space,
> don't worry".
Also guests are not treated identically, host can decide whom to offer the free pages first (offering free pages will cause the guest some performance drop).
Best,
Wei
Powered by blists - more mailing lists