From: Marcelo Tosatti Subject: Re: KVM: attempt async pf only if address is contained in vma Date: Tue, 19 Oct 2010 11:14:48 -0200 Message-ID: <20101019131448.GB3649@amt.cnet> References: <20101018222402.GA27350@amt.cnet> <20101019110522.GH10207@redhat.com> <20101019121727.GJ10207@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:21616 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758001Ab0JSNPA (ORCPT ); Tue, 19 Oct 2010 09:15:00 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9JDExk8004250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Oct 2010 09:14:59 -0400 Content-Disposition: inline In-Reply-To: <20101019121727.GJ10207@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Oct 19, 2010 at 02:17:27PM +0200, Gleb Natapov wrote: > On Tue, Oct 19, 2010 at 01:05:22PM +0200, Gleb Natapov wrote: > > On Mon, Oct 18, 2010 at 08:24:03PM -0200, Marcelo Tosatti wrote: > > > > > > Only attempt async pagefault if address is contained within vma. > > > > > > Signed-off-by: Marcelo Tosatti > > > > > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > > index 5d57ec9..a9cfbd2 100644 > > > --- a/virt/kvm/kvm_main.c > > > +++ b/virt/kvm/kvm_main.c > > > @@ -996,8 +996,9 @@ static pfn_t hva_to_pfn(struct kvm *kvm, unsigned long addr, bool atomic, > > > > > > if (vma == NULL || addr < vma->vm_start || > > > !(vma->vm_flags & VM_PFNMAP)) { > > > - if (async && !(vma->vm_flags & VM_PFNMAP) && > > > - (vma->vm_flags & VM_WRITE)) > > > + if (async && vma && !(vma->vm_flags & VM_PFNMAP) && > > actually we should check for addr < vma->vm_start here too. find_vma() > > is very strange function. > > > > What about patch below (only compile tested for now)? > > > Works for me. Thats much nicer. > > - vma = find_vma(current->mm, addr); > > + vma = find_vma_intersection(current->mm, addr, addr+1); > > > > - if (vma == NULL || addr < vma->vm_start || > > - !(vma->vm_flags & VM_PFNMAP)) { > > - if (async && !(vma->vm_flags & VM_PFNMAP) && > > - (vma->vm_flags & VM_WRITE)) > > + if (vma == NULL) > > + return get_fault_pfn(); up_read(mmap_sem)