From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [patch 02/13] KVM: MMU: switch to get_user_pages_fast Date: Sun, 07 Sep 2008 11:45:41 +0300 Message-ID: <48C394B5.20706@qumranet.com> References: <20080906184822.560099087@localhost.localdomain> <20080906192430.598327536@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Andrea Arcangeli To: Marcelo Tosatti Return-path: Received: from il.qumranet.com ([212.179.150.194]:54578 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752197AbYIGIpm (ORCPT ); Sun, 7 Sep 2008 04:45:42 -0400 In-Reply-To: <20080906192430.598327536@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: Marcelo Tosatti wrote: > Avoid mmap_sem / pt lock acquision if the pagetables are present. The > improvement for hugepage backed guests is more significant, since pte > walk + page grab for such mappings is serialized by mm->page_table_lock. > > CC: Andrea Arcangeli > > I'd like to apply this. Andrea, can you verify that mmu notifiers interaction is okay? > > static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) > { > + struct page *page[1]; > + unsigned long addr; > + int npages; > + gfn_t gfn = vmf->pgoff; > struct kvm *kvm = vma->vm_file->private_data; > - struct page *page; > > - if (!kvm_is_visible_gfn(kvm, vmf->pgoff)) > + addr = gfn_to_hva(kvm, gfn); > + if (kvm_is_error_hva(addr)) > return VM_FAULT_SIGBUS; > - page = gfn_to_page(kvm, vmf->pgoff); > - if (is_error_page(page)) { > - kvm_release_page_clean(page); > + > + npages = get_user_pages(current, current->mm, addr, 1, 1, 0, page, > + NULL); > + if (unlikely(npages != 1)) > return VM_FAULT_SIGBUS; > - } > - vmf->page = page; > + > + vmf->page = page[0]; > return 0; > } > > Why this change? -- error compiling committee.c: too many arguments to function