From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [RFC] Expose infrastructure for unpinning guest memory Date: Sat, 13 Oct 2007 09:21:31 +0200 Message-ID: <471071FB.9080808@qumranet.com> References: <1192138344500-git-send-email-aliguori@us.ibm.com> <470F14F2.7050800@qumranet.com> <470FC25A.70607@us.ibm.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: Anthony Liguori Return-path: In-Reply-To: <470FC25A.70607-r/Jw6+rmf7HQT0dZR+AlfA@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 Anthony Liguori wrote: > 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)? > > I think so. The docs aren't clear. See also MADV_DONTNEED. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ------------------------------------------------------------------------- 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/