From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nadav Amit Subject: Re: [patch 2/4] KVM: MMU: allow pinning spte translations (TDP-only) Date: Thu, 17 Jul 2014 20:18:03 +0300 Message-ID: <53C8054B.5080604@gmail.com> References: <20140709191250.408928362@amt.cnet> <20140709191611.207208253@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: pbonzini@redhat.com, xiaoguangrong@linux.vnet.ibm.com, gleb@kernel.org, avi.kivity@gmail.com To: mtosatti@redhat.com, kvm@vger.kernel.org, ak@linux.intel.com Return-path: Received: from mail-we0-f170.google.com ([74.125.82.170]:50435 "EHLO mail-we0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750801AbaGQRSJ (ORCPT ); Thu, 17 Jul 2014 13:18:09 -0400 Received: by mail-we0-f170.google.com with SMTP id w62so3398502wes.1 for ; Thu, 17 Jul 2014 10:18:07 -0700 (PDT) In-Reply-To: <20140709191611.207208253@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: Small question if I may regarding kvm_mmu_pin_pages: On 7/9/14, 10:12 PM, mtosatti@redhat.com wrote: > + > +static int kvm_mmu_pin_pages(struct kvm_vcpu *vcpu) > +{ > + struct kvm_pinned_page_range *p; > + int r = 1; > + > + if (is_guest_mode(vcpu)) > + return r; > + > + if (!vcpu->arch.mmu.direct_map) > + return r; > + > + ASSERT(VALID_PAGE(vcpu->arch.mmu.root_hpa)); > + > + list_for_each_entry(p, &vcpu->arch.pinned_mmu_pages, link) { > + gfn_t gfn_offset; > + > + for (gfn_offset = 0; gfn_offset < p->npages; gfn_offset++) { > + gfn_t gfn = p->base_gfn + gfn_offset; > + int r; > + bool pinned = false; > + > + r = vcpu->arch.mmu.page_fault(vcpu, gfn << PAGE_SHIFT, > + PFERR_WRITE_MASK, false, > + true, &pinned); I understand that the current use-case is for pinning only few pages. Yet, wouldn't it be better (for performance) to check whether the gfn uses a large page and if so to skip forward, increasing gfn_offset to point to the next large page? Thanks, Nadav