From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Swapping out kvm pages Date: Wed, 11 Apr 2007 17:41:45 +0300 Message-ID: <461CF3A9.8040804@qumranet.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Chen Haogang Return-path: In-Reply-To: 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 Chen Haogang wrote: > > In kvm's TODO page, I saw the item "attach kvm memory to a Linux > address_space so that guest memory can be paged out". But I don't > think it is as simple as this. Because both host part page fault and > guest part page fault interact. > > As I know, the creation of guest's shadow PTEs don't go through host's > PTEs. When a shadow PTE is to be created, it always assumes the page > pointer stored in memory region is vaild, and use the page struct to > calcuate host physical address. > > So, if we want to implement a swap mechanism. It is important to mark > the page struct pointer as invalid when host frame is swapped out. And > replace the page pointer with the new one when a frame is swapped in. > > Moreover, we should not swapped out pages that are currently mapped by > shadow PTEs unless we got a way to invalidate them. On the guest part, > when a shadow PTE is to be created, we should make sure the page > pointer in memory regeion is vaild ( i.e. the page is not swapped > out), if not, we should ask to host to bring in the page before guest > can resume. > > I want to know if I misunderstood anything, and wonder if there's any > easier way to implement guest pages' swapping? > > That's what I had in mind. I don't know exactly how you prevent a page from being swapped; maybe it involves the page locked page flag, or maybe just incrementing its reference count is enough. Paging in is probably simpler; if the page isn't in the page cache, bring it in and attach it to the shadow page table. The only complication I see is with the upcoming nested/extended page tables, which want shadow page tables for *all* guest pages, making this scheme fail. We can make npt/ept demand paged like current shadow paging, but it seems to be a pessimization. -- error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV