kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org,
	yoshikawa.takuya@oss.ntt.co.jp, xiaoguangrong@cn.fujitsu.com,
	Joerg.Roedel@amd.com
Subject: Re: [PATCH 1/1 v2] KVM: MMU: Optimize guest page table walk
Date: Mon, 25 Apr 2011 10:04:43 +0200	[thread overview]
Message-ID: <4DB52B1B.5080407@web.de> (raw)
In-Reply-To: <20110422003444.5b3a876a.takuya.yoshikawa@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2222 bytes --]

On 2011-04-21 17:34, Takuya Yoshikawa wrote:
> From: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
> 
> This patch optimizes the guest page table walk by using get_user()
> instead of copy_from_user().
> 
> With this patch applied, paging64_walk_addr_generic() has become
> about 0.5us to 1.0us faster on my Phenom II machine with NPT on.
> 
> Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
> ---
>  arch/x86/kvm/paging_tmpl.h |   23 ++++++++++++++++++++---
>  1 files changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
> index 74f8567..825d953 100644
> --- a/arch/x86/kvm/paging_tmpl.h
> +++ b/arch/x86/kvm/paging_tmpl.h
> @@ -117,6 +117,7 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
>  				    gva_t addr, u32 access)
>  {
>  	pt_element_t pte;
> +	pt_element_t __user *ptep_user;
>  	gfn_t table_gfn;
>  	unsigned index, pt_access, uninitialized_var(pte_access);
>  	gpa_t pte_gpa;
> @@ -152,6 +153,9 @@ walk:
>  	pt_access = ACC_ALL;
>  
>  	for (;;) {
> +		gfn_t real_gfn;
> +		unsigned long host_addr;
> +
>  		index = PT_INDEX(addr, walker->level);
>  
>  		table_gfn = gpte_to_gfn(pte);
> @@ -160,9 +164,22 @@ walk:
>  		walker->table_gfn[walker->level - 1] = table_gfn;
>  		walker->pte_gpa[walker->level - 1] = pte_gpa;
>  
> -		if (kvm_read_guest_page_mmu(vcpu, mmu, table_gfn, &pte,
> -					    offset, sizeof(pte),
> -					    PFERR_USER_MASK|PFERR_WRITE_MASK)) {
> +		real_gfn = mmu->translate_gpa(vcpu, gfn_to_gpa(table_gfn),
> +					      PFERR_USER_MASK|PFERR_WRITE_MASK);
> +		if (real_gfn == UNMAPPED_GVA) {
> +			present = false;
> +			break;
> +		}
> +		real_gfn = gpa_to_gfn(real_gfn);
> +
> +		host_addr = gfn_to_hva(vcpu->kvm, real_gfn);
> +		if (kvm_is_error_hva(host_addr)) {
> +			present = false;
> +			break;
> +		}
> +
> +		ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
> +		if (get_user(pte, ptep_user)) {
                    ^^^^^^^^^^^^
This doesn't work for x86-32: pte is 64 bit, but get_user is only
defined up to 32 bit on that platform.

Avi, what's your 32-bit buildbot doing? :)

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

  parent reply	other threads:[~2011-04-25  8:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-21 15:32 [PATCH 0/1 v2] KVM: MMU: Optimize guest page table walk Takuya Yoshikawa
2011-04-21 15:34 ` [PATCH 1/1 " Takuya Yoshikawa
2011-04-24  7:27   ` Avi Kivity
2011-04-24 13:15     ` Takuya Yoshikawa
2011-04-25  8:04   ` Jan Kiszka [this message]
2011-04-25  8:32     ` Takuya Yoshikawa
2011-04-25  9:15       ` Jan Kiszka
2011-04-26  4:50         ` Takuya Yoshikawa
2011-04-26  6:34           ` Jan Kiszka
2011-04-26 14:40             ` Takuya Yoshikawa
2011-04-26 14:54               ` Avi Kivity
2011-04-26 15:13                 ` Takuya Yoshikawa
2011-04-26 17:15                   ` Avi Kivity
2011-04-26 16:26                 ` Takuya Yoshikawa
2011-04-26 17:16                   ` Avi Kivity
2011-04-26  7:42     ` Avi Kivity
2011-04-26  7:45       ` Jan Kiszka
2011-04-26  8:21         ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DB52B1B.5080407@web.de \
    --to=jan.kiszka@web.de \
    --cc=Joerg.Roedel@amd.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=takuya.yoshikawa@gmail.com \
    --cc=xiaoguangrong@cn.fujitsu.com \
    --cc=yoshikawa.takuya@oss.ntt.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).