public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bandan Das <bsd@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, gleb@kernel.org
Subject: Re: [PATCH 12/25] KVM: emulate: extend memory access optimization to stores
Date: Mon, 09 Jun 2014 14:40:19 -0400	[thread overview]
Message-ID: <jpg61kaexkc.fsf@redhat.com> (raw)
In-Reply-To: <1402318753-23362-13-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Mon, 9 Jun 2014 14:59:00 +0200")

Paolo Bonzini <pbonzini@redhat.com> writes:

> Even on a store the optimization saves about 50 clock cycles,
> mostly because the jump in write_memory_operand becomes much more
> predictable.
>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Isn't the reviewed-by automatically implied ? :)

> ---
>  arch/x86/kvm/emulate.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 594cb560947c..eaf0853ffaf9 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -1589,7 +1589,7 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
>  
>  static int prepare_memory_operand(struct x86_emulate_ctxt *ctxt,
>  				  struct operand *op,
> -				  bool write)
> +				  bool read, bool write)
>  {
>  	int rc;
>  	unsigned long gva;
> @@ -1605,6 +1605,10 @@ static int prepare_memory_operand(struct x86_emulate_ctxt *ctxt,
>  	if (rc != X86EMUL_CONTINUE)
>  		return rc;
>  
> +	/* optimisation - avoid slow emulated read if Mov */
> +	if (!read)
> +		return X86EMUL_CONTINUE;
> +
>  	if (likely(!kvm_is_error_hva(op->hva))) {
>  		rc = read_from_user(ctxt, op->hva, &op->val, size);
>  		if (!write)
> @@ -4699,14 +4703,14 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
>  	}
>  
>  	if ((ctxt->src.type == OP_MEM) && !(ctxt->d & NoAccess)) {
> -		rc = prepare_memory_operand(ctxt, &ctxt->src, false);
> +		rc = prepare_memory_operand(ctxt, &ctxt->src, true, false);
>  		if (rc != X86EMUL_CONTINUE)
>  			goto done;
>  		ctxt->src.orig_val64 = ctxt->src.val64;
>  	}
>  
>  	if (ctxt->src2.type == OP_MEM) {
> -		rc = prepare_memory_operand(ctxt, &ctxt->src2, false);
> +		rc = prepare_memory_operand(ctxt, &ctxt->src2, true, false);
>  		if (rc != X86EMUL_CONTINUE)
>  			goto done;
>  	}
> @@ -4715,9 +4719,9 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
>  		goto special_insn;
>  
>  
> -	if ((ctxt->dst.type == OP_MEM) && !(ctxt->d & Mov)) {
> -		/* optimisation - avoid slow emulated read if Mov */
> +	if (ctxt->dst.type == OP_MEM) {
>  		rc = prepare_memory_operand(ctxt, &ctxt->dst,
> +					    !(ctxt->d & Mov),
>  					    !(ctxt->d & NoWrite));
>  		if (rc != X86EMUL_CONTINUE)
>  			goto done;

  reply	other threads:[~2014-06-09 18:40 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-09 12:58 [PATCH 00/25] KVM: x86: Speed up emulation of invalid state Paolo Bonzini
2014-06-09 12:58 ` [PATCH 01/25] KVM: vmx: speed up emulation of invalid guest state Paolo Bonzini
2014-06-09 12:58 ` [PATCH 02/25] KVM: x86: return all bits from get_interrupt_shadow Paolo Bonzini
2014-06-09 12:58 ` [PATCH 03/25] KVM: x86: avoid useless set of KVM_REQ_EVENT after emulation Paolo Bonzini
2014-06-09 12:58 ` [PATCH 04/25] KVM: emulate: move around some checks Paolo Bonzini
2014-06-09 12:58 ` [PATCH 05/25] KVM: emulate: protect checks on ctxt->d by a common "if (unlikely())" Paolo Bonzini
2014-06-09 12:58 ` [PATCH 06/25] KVM: emulate: speed up emulated moves Paolo Bonzini
2014-06-09 12:58 ` [PATCH 07/25] KVM: emulate: simplify writeback Paolo Bonzini
2014-06-09 12:58 ` [PATCH 08/25] KVM: emulate: abstract handling of memory operands Paolo Bonzini
2014-06-09 12:58 ` [PATCH 09/25] KVM: export mark_page_dirty_in_slot Paolo Bonzini
2014-06-09 12:58 ` [PATCH 10/25] KVM: emulate: introduce memory_prepare callback to speed up memory access Paolo Bonzini
2014-06-09 12:58 ` [PATCH 11/25] KVM: emulate: activate memory access optimization Paolo Bonzini
2014-06-09 12:59 ` [PATCH 12/25] KVM: emulate: extend memory access optimization to stores Paolo Bonzini
2014-06-09 18:40   ` Bandan Das [this message]
2014-06-19 11:37     ` Paolo Bonzini
2014-06-09 12:59 ` [PATCH 13/25] KVM: emulate: move init_decode_cache to emulate.c Paolo Bonzini
2014-06-09 12:59 ` [PATCH 14/25] KVM: emulate: Remove ctxt->intercept and ctxt->check_perm checks Paolo Bonzini
2014-06-09 12:59 ` [PATCH 15/25] KVM: emulate: cleanup decode_modrm Paolo Bonzini
2014-06-09 12:59 ` [PATCH 16/25] KVM: emulate: clean up initializations in init_decode_cache Paolo Bonzini
2014-06-09 12:59 ` [PATCH 17/25] KVM: emulate: rework seg_override Paolo Bonzini
2014-06-09 12:59 ` [PATCH 18/25] KVM: emulate: do not initialize memopp Paolo Bonzini
2014-06-09 12:59 ` [PATCH 19/25] KVM: emulate: speed up do_insn_fetch Paolo Bonzini
2014-06-09 12:59 ` [PATCH 20/25] KVM: emulate: avoid repeated calls to do_insn_fetch_bytes Paolo Bonzini
2014-06-09 12:59 ` [PATCH 21/25] KVM: emulate: avoid per-byte copying in instruction fetches Paolo Bonzini
2014-06-09 12:59 ` [PATCH 22/25] KVM: emulate: put pointers in the fetch_cache Paolo Bonzini
2014-06-09 12:59 ` [PATCH 23/25] KVM: x86: use kvm_read_guest_page for emulator accesses Paolo Bonzini
2014-06-09 12:59 ` [PATCH 24/25] KVM: emulate: simplify BitOp handling Paolo Bonzini
2014-06-09 12:59 ` [PATCH 25/25] KVM: emulate: fix harmless typo in MMX decoding Paolo Bonzini

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=jpg61kaexkc.fsf@redhat.com \
    --to=bsd@redhat.com \
    --cc=gleb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@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