From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [RFC] Expose infrastructure for unpinning guest memory Date: Fri, 12 Oct 2007 13:52:10 -0500 Message-ID: <470FC25A.70607@us.ibm.com> References: <1192138344500-git-send-email-aliguori@us.ibm.com> <470F14F2.7050800@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Avi Kivity Return-path: In-Reply-To: <470F14F2.7050800-atKUWr5tajBWk0Htik3J/w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Avi Kivity wrote: > Anthony Liguori wrote: > >> Now that we have userspace memory allocation, I wanted to play with ballooning. >> The idea is that when a guest "balloons" down, we simply unpin the underlying >> physical memory and the host kernel may or may not swap it. To reclaim >> ballooned memory, the guest can just start using it and we'll pin it on demand. >> >> The following patch is a stab at providing the right infrastructure for pinning >> and automatic repinning. I don't have a lot of comfort in the MMU code so I >> thought I'd get some feedback before going much further. >> >> gpa_to_hpa is a little awkward to hook, but it seems like the right place in the >> code. I'm most uncertain about the SMP safety of the unpinning. Presumably, >> I have to hold the kvm lock around the mmu_unshadow and page_cache release to >> ensure that another VCPU doesn't fault the page back in after mmu_unshadow? >> >> >> > > One we have true swapping capabilities (which imply ability for the > kernel to remove a page from the shadow page tables) you can unpin by > calling munmap() or madvise(MADV_REMOVE) on the pages to be unpinned. > So does MADV_REMOVE remove the backing page but still allow for memory to be faulted in? That is, after calling MADV_REMOVE, there's no guarantee that the contents of a give VA range will remain the same (but it won't SEGV the app if it accesses that memory)? If so, I think that would be the right way to treat it. That allows for two types of hints for the guest to provide: 1) I won't access this memory for a very long time (so it's a good candidate to swap out) and 2) I won't access this memory and don't care about it's contents. Regards, Anthony Liguori > Other than that the approach seems right. > > ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/