From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [patch 3/5] KVM: add kvm_follow_page() Date: Mon, 24 Dec 2007 09:26:24 -0500 Message-ID: <20071224142624.GA20275@dmt> References: <20071223052513.GA19072@dmt> <476E083B.5040600@qumranet.com> <476E1F23.3020609@qumranet.com> <476E236A.9000800@qumranet.com> <20071223012618.e8cf8320.akpm@linux-foundation.org> <476E39F2.4030202@qumranet.com> <20071223025245.d839c86d.akpm@linux-foundation.org> <476E4005.90003@qumranet.com> <20071223201525.GA14259@dmt> <476F5801.2030002@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm-devel , Andrew Morton , Matt Mackall To: Avi Kivity Return-path: Content-Disposition: inline In-Reply-To: <476F5801.2030002-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 On Mon, Dec 24, 2007 at 08:56:01AM +0200, Avi Kivity wrote: > Marcelo Tosatti wrote: > >It can acquire the pagetablelock in the callback handler. But then, > >vm_normal_page() must also be exported. > > > >Are you guys OK with this ? > > > > > > Seems to me that requires fairly detailed mucking in mm details, just to > get at a page. I agree. > I believe that a new get_users_pages_inatomic() is more suitable; > Andrew, I'll write it if you agree. Alternatively, walk_page_range() > should take the lock itself, otherwise it is only usable if you don't > care about correctness? Why not just export follow_page() ? That is exactly what KVM needs. > >+static int kvm_pte_range(pmd_t *pmd, unsigned long addr, unsigned long > >end, > >+ void *private) > >+{ > >+ struct page **page = private; > >+ struct vm_area_struct *vma; > >+ pte_t *ptep, pte; > >+ spinlock_t *ptl; > >+ int err = -EFAULT; > >+ > >+ vma = find_vma(current->mm, addr); > >+ if (!vma) > >+ return err; > >+ > >+ ptep = pte_offset_map_lock(current->mm, pmd, addr, &ptl); > >+ pte = *ptep; > >+ if (!pte_present(pte)) > >+ goto unlock; > >+ > >+ *page = vm_normal_page(vma, addr, pte); > >+ if (!*page) > >+ goto unlock; > >+ > >+ get_page(*page); > >+ err = 0; > >+unlock: > >+ pte_unmap_unlock(ptep, ptl); > >+ return err; > >+} > >+ > > > > See what one has to write to get at a page? Unreasonable IMO. And > that's without hugetlb support AFAICT (kvm will want that soon). Indeed... Its pretty much duplicating what follow_page() already does. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/