Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1384280 > unrolled thread
| Started by | Greg Kurz <gkurz@linux.vnet.ibm.com> |
|---|---|
| First post | 2016-04-21 16:20 +0200 |
| Last post | 2016-04-27 16:50 +0200 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v4 1/2] KVM: remove NULL return path for vcpu ids >= KVM_MAX_VCPUS Greg Kurz <gkurz@linux.vnet.ibm.com> - 2016-04-21 16:20 +0200
Re: [PATCH v4 1/2] KVM: remove NULL return path for vcpu ids >= KVM_MAX_VCPUS Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-04-26 09:50 +0200
Re: [PATCH v4 1/2] KVM: remove NULL return path for vcpu ids >= KVM_MAX_VCPUS Gerg Kurz <gkurz@linux.vnet.ibm.com> - 2016-04-27 11:50 +0200
Re: [PATCH v4 1/2] KVM: remove NULL return path for vcpu ids >= KVM_MAX_VCPUS Radim Krčmář <rkrcmar@redhat.com> - 2016-04-27 16:50 +0200
| From | Greg Kurz <gkurz@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-04-21 16:20 +0200 |
| Subject | [PATCH v4 1/2] KVM: remove NULL return path for vcpu ids >= KVM_MAX_VCPUS |
| Message-ID | <rqnCx-1Zd-17@gated-at.bofh.it> |
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);
if (vcpu && vcpu->vcpu_id == id)
return vcpu;
kvm_for_each_vcpu(i, vcpu, kvm)
[toc] | [next] | [standalone]
| From | Cornelia Huck <cornelia.huck@de.ibm.com> |
|---|---|
| Date | 2016-04-26 09:50 +0200 |
| Message-ID | <rs5US-3CS-15@gated-at.bofh.it> |
| In reply to | #1384280 |
On Thu, 21 Apr 2016 16:15:05 +0200
Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:
> 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(-)
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
[toc] | [prev] | [next] | [standalone]
| From | Gerg Kurz <gkurz@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-04-27 11:50 +0200 |
| Message-ID | <rsugy-7q8-27@gated-at.bofh.it> |
| In reply to | #1384280 |
Quoting Greg Kurz <gkurz@linux.vnet.ibm.com>:
> 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>
> ---
Radim,
I think this sanity check is only needed because kvm_get_vcpu() use the
id as an index in kvm->vcpus[]. Checking against the new KVM_MAX_VCPU_ID
would be clearly wrong here.
And this patch got two R-b tags already. Do you agree we keep it ?
Cheers.
--
Greg
> 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);
> if (vcpu && vcpu->vcpu_id == id)
> return vcpu;
> kvm_for_each_vcpu(i, vcpu, kvm)
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[toc] | [prev] | [next] | [standalone]
| From | Radim Krčmář <rkrcmar@redhat.com> |
|---|---|
| Date | 2016-04-27 16:50 +0200 |
| Message-ID | <rsyWS-2P1-19@gated-at.bofh.it> |
| In reply to | #1388852 |
2016-04-27 05:40-0400, Gerg Kurz:
> Quoting Greg Kurz <gkurz@linux.vnet.ibm.com>:
>
>> 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>
>> ---
>
> Radim,
>
> I think this sanity check is only needed because kvm_get_vcpu() use the
> id as an index in kvm->vcpus[]. Checking against the new KVM_MAX_VCPU_ID
> would be clearly wrong here.
I agree, checking KVM_MAX_VCPU_ID would be pointless.
> And this patch got two R-b tags already. Do you agree we keep it ?
Yes, thanks.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web