public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm-devel <kvm@vger.kernel.org>
Subject: Re: KVM: avoid unnecessary memcpy in kvm_emulate_pio
Date: Sun, 25 May 2008 14:39:26 +0300	[thread overview]
Message-ID: <48394FEE.1030404@qumranet.com> (raw)
In-Reply-To: <20080525004133.GA14165@dmt>

Marcelo Tosatti wrote:
> When emulating in instructions there's no point in copying the
> destination register contents to vcpu->arch.pio_data since it will be
> overwritten by the ioport handler.
>
> Also remove the ->decache_regs() call, since as you mentioned there is
> no register change to writeback.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index e537005..f43f770 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2254,8 +2254,8 @@ int kvm_emulate_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
>  			    handler);
>  
>  	kvm_x86_ops->cache_regs(vcpu);
> -	memcpy(vcpu->arch.pio_data, &vcpu->arch.regs[VCPU_REGS_RAX], 4);
> -	kvm_x86_ops->decache_regs(vcpu);
> +	if (!in)
> +		memcpy(vcpu->arch.pio_data, &vcpu->arch.regs[VCPU_REGS_RAX], 4);
>  
>  	kvm_x86_ops->skip_emulated_instruction(vcpu);
>  

The memcpy() compiles to just one mov instruction, so I didn't change 
it.  I dropped the ->decache_regs() call (as it can take 100 cycles on 
Intel).

-- 
error compiling committee.c: too many arguments to function


      reply	other threads:[~2008-05-25 11:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-25  0:41 KVM: avoid unnecessary memcpy in kvm_emulate_pio Marcelo Tosatti
2008-05-25 11:39 ` Avi Kivity [this message]

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=48394FEE.1030404@qumranet.com \
    --to=avi@qumranet.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /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