From: Avi Kivity <avi@qumranet.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm-devel <kvm@vger.kernel.org>
Subject: Re: RFC: cache_regs in kvm_emulate_pio
Date: Fri, 20 Jun 2008 23:30:05 +0300 [thread overview]
Message-ID: <485C134D.2070905@qumranet.com> (raw)
In-Reply-To: <20080619233123.GA24183@dmt.cnet>
Marcelo Tosatti wrote:
> Hi,
>
> From my understanding the ->cache_regs call on kvm_emulate_pio() is
> necessary only on AMD, where vcpu->arch.regs[RAX] is not copied during
> exit in svm_vcpu_load().
>
> On both architectures, the remaining general purpose registers are saved
> on exit.
>
> The following patch saves 100 cycles out of both light and heavy exits
> on Intel (if correct, kvm_emulate_hypercall and complete_pio could also
> benefit, thus saving 200 cycles for in-kernel devices).
>
ISTR vmwrite as 50 cycles and vmread as much lower.
> BTW, the decache_regs(vcpu) call at the end of complete_pio() could also
> be a noop on Intel from what I can tell ?
>
>
I think so. decache_regs() is actually more important.
> diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
> index 851184d..95a0736 100644
> --- a/include/asm-x86/kvm_host.h
> +++ b/include/asm-x86/kvm_host.h
> @@ -410,6 +410,7 @@ struct kvm_x86_ops {
> unsigned long (*get_dr)(struct kvm_vcpu *vcpu, int dr);
> void (*set_dr)(struct kvm_vcpu *vcpu, int dr, unsigned long value,
> int *exception);
> + void (*cache_rax)(struct kvm_vcpu *vcpu);
> void (*cache_regs)(struct kvm_vcpu *vcpu);
> void (*decache_regs)(struct kvm_vcpu *vcpu);
> unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
>
ugh, another callback. how about instead
/* in vcpu structure */
u16 regs_available;
u16 regs_dirty;
/* read from cache if possible */
if (!test_bit(VCPU_REG_RAX, ®s_available))
->cache_regs();
printk("%d\n", regs[VCPU_REGS_RAX]);
/* write to cache, ->vcpu_run() will flush */
regs[VCPU_REGS_RAX] = 17;
__set_bit(VCPU_REGS_RAX, ®s_dirty);
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
next prev parent reply other threads:[~2008-06-20 20:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-19 23:31 RFC: cache_regs in kvm_emulate_pio Marcelo Tosatti
2008-06-20 20:30 ` Avi Kivity [this message]
2008-06-20 21:24 ` Marcelo Tosatti
2008-06-21 7:04 ` Avi Kivity
-- strict thread matches above, loose matches on Subject: below --
2008-06-21 19:46 Marcelo Tosatti
2008-06-22 5:16 ` Avi Kivity
2008-06-22 18:05 ` Marcelo Tosatti
2008-06-24 19:33 ` Marcelo Tosatti
2008-06-26 9:18 ` Avi Kivity
2008-06-26 14:52 ` Marcelo Tosatti
2008-06-26 22:15 ` Marcelo Tosatti
2008-06-27 2:28 ` Marcelo Tosatti
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=485C134D.2070905@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