linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
To: Greg Kurz <gkurz@linux.vnet.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	james.hogan@imgtec.com, mingo@redhat.com,
	linux-mips@linux-mips.org, kvm@vger.kernel.org,
	rkrcmar@redhat.com, linux-kernel@vger.kernel.org,
	qemu-ppc@nongnu.org, Cornelia Huck <cornelia.huck@de.ibm.com>,
	Paul Mackerras <paulus@samba.org>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v4 1/2] KVM: remove NULL return path for vcpu ids >= KVM_MAX_VCPUS
Date: Thu, 21 Apr 2016 16:17:29 +0200	[thread overview]
Message-ID: <20160421161729.2f430008@thinkpad-w530> (raw)
In-Reply-To: <146124810201.32509.2946887043729554992.stgit@bahia.huguette.org>

> Commit c896939f7cff ("KVM: use heuristic for fast VCPU lookup by id") added
> a return path that prevents vcpu ids to exceed KVM_MAX_VCPUS. This is a
> problem for powerpc where vcpu ids can grow up to 8*KVM_MAX_VCPUS.
> 
> This patch simply reverses the logic so that we only try fast path if the
> vcpu id can be tried as an index in kvm->vcpus[]. The slow path is not
> affected by the change.
> 
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> ---
>  include/linux/kvm_host.h |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index 5276fe0916fc..23bfe1bd159c 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -447,12 +447,13 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
> 
>  static inline struct kvm_vcpu *kvm_get_vcpu_by_id(struct kvm *kvm, int id)
>  {
> -	struct kvm_vcpu *vcpu;
> +	struct kvm_vcpu *vcpu = NULL;
>  	int i;
> 
> -	if (id < 0 || id >= KVM_MAX_VCPUS)
> +	if (id < 0)
>  		return NULL;
> -	vcpu = kvm_get_vcpu(kvm, id);
> +	if (id < KVM_MAX_VCPUS)
> +		vcpu = kvm_get_vcpu(kvm, id);

Maybe this check even should go into kvm_get_vcpu()

>  	if (vcpu && vcpu->vcpu_id == id)
>  		return vcpu;
>  	kvm_for_each_vcpu(i, vcpu, kvm)
> 

Anyhow,

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>

David

  reply	other threads:[~2016-04-21 14:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21 14:14 [PATCH v4 0/2] let archs decide for vcpu ids Greg Kurz
2016-04-21 14:15 ` [PATCH v4 1/2] KVM: remove NULL return path for vcpu ids >= KVM_MAX_VCPUS Greg Kurz
2016-04-21 14:17   ` David Hildenbrand [this message]
2016-04-21 14:30     ` Greg Kurz
2016-04-26  7:44   ` Cornelia Huck
2016-04-27  9:40   ` Gerg Kurz
2016-04-27 14:40     ` Radim Krčmář
2016-04-21 14:20 ` [PATCH v4 2/2] KVM: move vcpu id checking to archs Greg Kurz
2016-04-21 16:00   ` Radim Krčmář
2016-04-21 16:45     ` Greg Kurz
2016-04-21 17:36       ` Radim Krčmář
2016-04-22  9:25         ` Greg Kurz
2016-04-22 10:22           ` Cornelia Huck
2016-04-22 11:19           ` Igor Mammedov
2016-04-22 13:48             ` Radim Krčmář
2016-04-22 13:40           ` Radim Krčmář
2016-04-22 14:50             ` Greg Kurz
2016-04-25 14:15               ` Radim Krčmář
2016-04-25 14:30                 ` Greg Kurz
2016-04-22  9:21   ` Wei Yang
2016-04-22  9:30     ` Greg Kurz
2016-04-23  0:51       ` Wei Yang

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=20160421161729.2f430008@thinkpad-w530 \
    --to=dahi@linux.vnet.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=gkurz@linux.vnet.ibm.com \
    --cc=james.hogan@imgtec.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-ppc@nongnu.org \
    --cc=rkrcmar@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;
as well as URLs for NNTP newsgroup(s).