From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Peter Xu <peterx@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 03/17] KVM: monolithic: x86: handle the request_immediate_exit variation
Date: Mon, 23 Sep 2019 16:45:00 -0700 [thread overview]
Message-ID: <20190923234500.GR18195@linux.intel.com> (raw)
In-Reply-To: <20190923230626.GF19996@redhat.com>
On Mon, Sep 23, 2019 at 07:06:26PM -0400, Andrea Arcangeli wrote:
> On Mon, Sep 23, 2019 at 03:35:26PM -0700, Sean Christopherson wrote:
> > On Fri, Sep 20, 2019 at 05:24:55PM -0400, Andrea Arcangeli wrote:
> > > request_immediate_exit is one of those few cases where the pointer to
> > > function of the method isn't fixed at build time and it requires
> > > special handling because hardware_setup() may override it at runtime.
> > >
> > > Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
> > > ---
> > > arch/x86/kvm/vmx/vmx_ops.c | 5 ++++-
> > > 1 file changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arch/x86/kvm/vmx/vmx_ops.c b/arch/x86/kvm/vmx/vmx_ops.c
> > > index cdcad73935d9..25d441432901 100644
> > > --- a/arch/x86/kvm/vmx/vmx_ops.c
> > > +++ b/arch/x86/kvm/vmx/vmx_ops.c
> > > @@ -498,7 +498,10 @@ int kvm_x86_ops_check_nested_events(struct kvm_vcpu *vcpu, bool external_intr)
> > >
> > > void kvm_x86_ops_request_immediate_exit(struct kvm_vcpu *vcpu)
> > > {
> > > - vmx_request_immediate_exit(vcpu);
> > > + if (likely(enable_preemption_timer))
> > > + vmx_request_immediate_exit(vcpu);
> > > + else
> > > + __kvm_request_immediate_exit(vcpu);
> >
> > Rather than wrap this in VMX code, what if we instead take advantage of a
> > monolithic module and add an inline to query enable_preemption_timer?
> > That'd likely save a few CALL/RET/JMP instructions and eliminate
> > __kvm_request_immediate_exit.
> >
> > E.g. something like:
> >
> > if (req_immediate_exit) {
> > kvm_make_request(KVM_REQ_EVENT, vcpu);
> > if (kvm_x86_has_request_immediate_exit())
> > kvm_x86_request_immediate_exit(vcpu);
> > else
> > smp_send_reschedule(vcpu->cpu);
> > }
>
> Yes, I mentioned the inlining possibilities in part of comment of
> 2/17:
>
> ===
> Further incremental minor optimizations that weren't possible before
> are now enabled by the monolithic model. For example it would be
> possible later to convert some of the small external methods to inline
> functions from the {svm,vmx}_ops.c file to kvm_ops.h. However that
> will require more Makefile tweaks.
> ===
With a straight rename to kvm_x86_<function>() instead of wrappers, we
shouldn't need kvm_ops.c. kvm_ops.h might be helpful, but it'd be just
as easy to keep them in kvm_host.h and would likely yield a more
insightful diff[*].
> To implement your kvm_x86_has_request_immediate_exit() we need more
> Makefile tweaking, basically we need a -D__SVM__ -D__VMX__ kind of
> thing so we can put an #ifdef __SVM__ in the kvm_ops.h equivalent to
> put inline code there. Or some other better solution if you think of
> any, that was my only idea so far with regard to inlining.
Hmm, I was thinking more along the lines of extending the kvm_host.h
pattern down into vendor specific code, e.g. arch/x86/kvm/vmx/kvm_host.h.
Probably with a different name though, two of those is confusing enough.
It'd still need Makefile changes, but we wouldn't litter the code with
#ifdefs. Future enhancments can also take advantage of the per-vendor
header to inline other things. Such a header would also make it possible
to fully remove kvm_x86_ops in this series (I think).
[*] Tying into the thought above, if we go for a straight rename and
eliminate the conditionally-implemented kvm_x86_ops ahead of time,
e.g. with inlines that return -EINVAL or something, then the
conversion to direct calls can be a straight replacement of
"kvm_x86_ops->" with "kvm_x86_" at the same time the declarations
are changed from members of kvm_x86_ops to externs.
Actually, typing out the above made me realize the immediate exit code
can be:
if (req_immediate_exit) {
kvm_make_request(KVM_REQ_EVENT, vcpu);
if (kvm_x86_request_immediate_exit(vcpu))
smp_send_reschedule(vcpu->cpu);
}
Where kvm_x86_request_immediate_exit() returns 0 on success, e.g. the SVM
implementation can be "return -EINVAL" or whatever is appropriate, which
I assume the compiler can optimize out. Or maybe a boolean return is
better in this case?
next prev parent reply other threads:[~2019-09-23 23:45 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-20 21:24 [PATCH 00/17] KVM monolithic v1 Andrea Arcangeli
2019-09-20 21:24 ` [PATCH 01/17] x86: spec_ctrl: fix SPEC_CTRL initialization after kexec Andrea Arcangeli
2019-09-23 10:22 ` Paolo Bonzini
2019-09-23 15:30 ` Sean Christopherson
2019-09-23 17:34 ` Andrea Arcangeli
2019-09-23 22:27 ` Sean Christopherson
2019-09-20 21:24 ` [PATCH 02/17] KVM: monolithic: x86: convert the kvm_x86_ops methods to external functions Andrea Arcangeli
2019-09-23 10:19 ` Paolo Bonzini
2019-09-23 16:13 ` Sean Christopherson
2019-09-23 16:51 ` Paolo Bonzini
2019-09-23 19:21 ` Andrea Arcangeli
2019-09-20 21:24 ` [PATCH 03/17] KVM: monolithic: x86: handle the request_immediate_exit variation Andrea Arcangeli
2019-09-23 22:35 ` Sean Christopherson
2019-09-23 23:06 ` Andrea Arcangeli
2019-09-23 23:45 ` Sean Christopherson [this message]
2019-09-24 0:24 ` Andrea Arcangeli
2019-09-20 21:24 ` [PATCH 04/17] KVM: monolithic: x86: convert the kvm_pmu_ops methods to external functions Andrea Arcangeli
2019-09-20 21:24 ` [PATCH 05/17] KVM: monolithic: x86: enable the kvm_x86_ops " Andrea Arcangeli
2019-09-20 21:24 ` [PATCH 06/17] KVM: monolithic: x86: enable the kvm_pmu_ops " Andrea Arcangeli
2019-09-20 21:24 ` [PATCH 07/17] KVM: monolithic: x86: adjust the section prefixes Andrea Arcangeli
2019-09-23 10:15 ` Paolo Bonzini
2019-09-25 12:13 ` Andrea Arcangeli
2019-09-25 12:32 ` Paolo Bonzini
2019-09-20 21:25 ` [PATCH 08/17] KVM: monolithic: adjust the section prefixes in the KVM common code Andrea Arcangeli
2019-09-20 21:25 ` [PATCH 09/17] KVM: monolithic: x86: remove kvm.ko Andrea Arcangeli
2019-09-20 21:25 ` [PATCH 10/17] KVM: monolithic: x86: use the external functions instead of kvm_x86_ops Andrea Arcangeli
2019-09-23 10:02 ` Paolo Bonzini
2019-09-20 21:25 ` [PATCH 11/17] KVM: monolithic: x86: remove exports Andrea Arcangeli
2019-09-20 21:25 ` [PATCH 12/17] KVM: monolithic: remove exports from KVM common code Andrea Arcangeli
2019-09-20 21:25 ` [PATCH 13/17] KVM: monolithic: x86: drop the kvm_pmu_ops structure Andrea Arcangeli
2019-09-23 10:21 ` Paolo Bonzini
2019-09-24 0:51 ` Andrea Arcangeli
2019-09-24 1:24 ` Paolo Bonzini
2019-09-20 21:25 ` [PATCH 14/17] KVM: monolithic: x86: inline more exit handlers in vmx.c Andrea Arcangeli
2019-09-23 10:19 ` Paolo Bonzini
2019-09-24 1:00 ` Andrea Arcangeli
2019-09-24 1:25 ` Paolo Bonzini
2019-09-24 1:55 ` Andrea Arcangeli
2019-09-24 2:56 ` Andrea Arcangeli
2019-09-25 7:52 ` Paolo Bonzini
2019-09-20 21:25 ` [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers Andrea Arcangeli
2019-09-23 9:31 ` Vitaly Kuznetsov
2019-09-23 9:57 ` Paolo Bonzini
2019-09-23 19:05 ` Andrea Arcangeli
2019-09-23 20:23 ` Sean Christopherson
2019-09-23 21:08 ` Andrea Arcangeli
2019-09-23 21:24 ` Sean Christopherson
2019-09-23 23:43 ` Andrea Arcangeli
2019-09-23 23:52 ` Sean Christopherson
2019-09-24 0:16 ` Paolo Bonzini
2019-09-24 0:35 ` Sean Christopherson
2019-09-24 0:37 ` Paolo Bonzini
2019-09-24 0:15 ` Paolo Bonzini
2019-09-24 0:38 ` Andrea Arcangeli
2019-09-24 0:46 ` Sean Christopherson
2019-09-24 21:46 ` Andrea Arcangeli
2019-09-25 7:50 ` Paolo Bonzini
2019-09-23 16:37 ` Sean Christopherson
2019-09-23 16:53 ` Paolo Bonzini
2019-09-23 17:42 ` Andrea Arcangeli
2019-09-23 18:15 ` Sean Christopherson
2019-09-23 19:12 ` Andrea Arcangeli
[not found] ` <E8FE7592-69C3-455E-8D80-A2D73BB2E14C@dinechin.org>
2019-09-25 20:51 ` Andrea Arcangeli
2019-09-23 16:28 ` Sean Christopherson
2019-09-20 21:25 ` [PATCH 16/17] KVM: retpolines: x86: eliminate retpoline from svm.c " Andrea Arcangeli
2019-09-23 10:01 ` Paolo Bonzini
2019-09-20 21:25 ` [PATCH 17/17] x86: retpolines: eliminate retpoline from msr event handlers Andrea Arcangeli
2019-09-23 15:39 ` [PATCH 00/17] KVM monolithic v1 Sean Christopherson
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=20190923234500.GR18195@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=aarcange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=vkuznets@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.