Re: [PATCH v5 8/9] KVM: MMU: combine guest pte read between fetchand pte prefetch

From: Marcelo Tosatti
Date: Tue Jul 06 2010 - 16:07:55 EST


On Tue, Jul 06, 2010 at 06:51:06PM +0800, Xiao Guangrong wrote:
> Combine guest pte read between guest pte check in the fetch path and pte prefetch
>
> Signed-off-by: Xiao Guangrong <xiaoguangrong@xxxxxxxxxxxxxx>
> ---
> arch/x86/kvm/paging_tmpl.h | 69 ++++++++++++++++++++++++++-----------------
> 1 files changed, 42 insertions(+), 27 deletions(-)
>
> diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
> index e04c1a4..a1e6d91 100644
> --- a/arch/x86/kvm/paging_tmpl.h
> +++ b/arch/x86/kvm/paging_tmpl.h
> @@ -67,6 +67,7 @@ struct guest_walker {
> int level;
> gfn_t table_gfn[PT_MAX_FULL_LEVELS];
> pt_element_t ptes[PT_MAX_FULL_LEVELS];
> + pt_element_t prefetch_ptes[PTE_PREFETCH_NUM];
> gpa_t pte_gpa[PT_MAX_FULL_LEVELS];
> unsigned pt_access;
> unsigned pte_access;
> @@ -291,12 +292,12 @@ static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
> gpte_to_gfn(gpte), pfn, true, true);
> }
>
> -static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, u64 *sptep)
> +static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, struct guest_walker *gw,
> + u64 *sptep)
> {
> struct kvm_mmu_page *sp;
> - pt_element_t gptep[PTE_PREFETCH_NUM];
> - gpa_t first_pte_gpa;
> - int offset = 0, index, i, j, max;
> + pt_element_t *gptep;
> + int index, i, j, max;
>
> sp = page_header(__pa(sptep));
> index = sptep - sp->spt;
> @@ -311,15 +312,7 @@ static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, u64 *sptep)
> i = index & ~(PTE_PREFETCH_NUM - 1);
> max = index | (PTE_PREFETCH_NUM - 1);
>
> - if (PTTYPE == 32)
> - offset = sp->role.quadrant << PT64_LEVEL_BITS;
> -
> - first_pte_gpa = gfn_to_gpa(sp->gfn) +
> - (offset + i) * sizeof(pt_element_t);
> -
> - if (kvm_read_guest_atomic(vcpu->kvm, first_pte_gpa, gptep,
> - sizeof(gptep)) < 0)
> - return;
> + gptep = gw->prefetch_ptes;

Where do you reread the gpte in the prefetch path?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/