linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: cdall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/15] KVM: Prepare for moving vcpu_load/vcpu_put into arch specific code
Date: Mon, 27 Nov 2017 20:58:30 +0100	[thread overview]
Message-ID: <20171127195830.GB16941@cbox> (raw)
In-Reply-To: <838db374-6040-c805-82f3-187a2cdfc40d@redhat.com>

On Mon, Nov 27, 2017 at 05:53:01PM +0100, Paolo Bonzini wrote:
> On 25/11/2017 21:57, Christoffer Dall wrote:
> > In preparation for moving calls to vcpu_load() and vcpu_put() into the
> > architecture specific implementations of the KVM vcpu ioctls, move the
> > calls in the main kvm_vcpu_ioctl() dispatcher function to each case
> > of the ioctl select statement.  This allows us to move the vcpu_load()
> > and vcpu_put() calls into architecture specific implementations of vcpu
> > ioctls, one by one.
> > 
> > Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> > ---
> >  virt/kvm/kvm_main.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++-----
> >  1 file changed, 48 insertions(+), 5 deletions(-)
> > 
> > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > index 9deb5a245b83..fafafcc38b5a 100644
> > --- a/virt/kvm/kvm_main.c
> > +++ b/virt/kvm/kvm_main.c
> > @@ -2528,16 +2528,15 @@ static long kvm_vcpu_ioctl(struct file *filp,
> >  		return kvm_arch_vcpu_ioctl(filp, ioctl, arg);
> >  #endif
> >  
> > -
> > -	r = vcpu_load(vcpu);
> > -	if (r)
> > -		return r;
> >  	switch (ioctl) {
> >  	case KVM_RUN: {
> >  		struct pid *oldpid;
> >  		r = -EINVAL;
> >  		if (arg)
> >  			goto out;
> > +		r = vcpu_load(vcpu);
> > +		if (r)
> > +			goto out;
> >  		oldpid = rcu_access_pointer(vcpu->pid);
> 
> If it is not a problem for ARM, maybe it would actually be best to leave
> the locking in kvm_vcpu_ioctl (with the already existing exception of
> KVM_INTERRUPT).  This would make vcpu_load void, and would also let you
> keep the PID adjustment in common code.  This would be more similar to
> the previous version, but without introducing __vcpu_load/__vcpu_put.

Yes, that's not a problem for ARM, and it was actually what I started
out with, and you can see the result here (rebased on v4.15-rc1):

git://git.kernel.org/pub/scm/linux/kernel/git/cdall/linux.git vcpu-load-put-keeplock

I got a bit into getting rid of the (IMHO) ugly ifdef-shortcut
dispatcher code, and thus reworked it to the submitted version.

Going back and looking, it's nicer to avoid the pid adjustment call, and
having vcpu_load be void is also convenient, but we're stuck with the
ifdef.  I guess I lean towards your suggestion as well, given that my
problem with the ifdef is not a technical one, but an aesthetic one.

> 
> Looks good apart from this doubt!  Thanks,
> 
Let me know if you want to have a quick glance at the branch above and
prefer that I send that as v2.

Thanks,
-Christoffer

  reply	other threads:[~2017-11-27 19:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-25 20:57 [PATCH 00/15] Move vcpu_load and vcpu_put calls to arch code Christoffer Dall
2017-11-25 20:57 ` [PATCH 01/15] KVM: Prepare for moving vcpu_load/vcpu_put into arch specific code Christoffer Dall
2017-11-27 16:53   ` Paolo Bonzini
2017-11-27 19:58     ` Christoffer Dall [this message]
2017-11-27 20:55       ` Paolo Bonzini
2017-11-25 20:57 ` [PATCH 02/15] KVM: Factor out vcpu->pid adjustment for KVM_RUN Christoffer Dall
2017-11-25 20:57 ` [PATCH 03/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run Christoffer Dall
2017-11-25 20:57 ` [PATCH 04/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_regs Christoffer Dall
2017-11-25 20:57 ` [PATCH 05/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_regs Christoffer Dall
2017-11-25 20:57 ` [PATCH 06/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_sregs Christoffer Dall
2017-11-25 20:57 ` [PATCH 07/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_sregs Christoffer Dall
2017-11-25 20:57 ` [PATCH 08/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_mpstate Christoffer Dall
2017-11-25 20:57 ` [PATCH 09/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_mpstate Christoffer Dall
2017-11-25 20:57 ` [PATCH 10/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_translate Christoffer Dall
2017-11-25 20:57 ` [PATCH 11/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_guest_debug Christoffer Dall
2017-11-27 19:28   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 12/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_fpu Christoffer Dall
2017-11-25 20:57 ` [PATCH 13/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu Christoffer Dall
2017-11-25 20:57 ` [PATCH 14/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl Christoffer Dall
2017-11-26  9:09   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 15/15] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN Christoffer Dall
2017-11-26  9:11 ` [PATCH 00/15] Move vcpu_load and vcpu_put calls to arch code Christoffer Dall
2017-11-28 20:55 ` David Hildenbrand
2017-11-28 21:29   ` 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=20171127195830.GB16941@cbox \
    --to=cdall@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).