From: Thomas Huth <thuth@redhat.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Alexander Graf <agraf@suse.de>, Paul Mackerras <paulus@samba.org>,
David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: KVM <kvm@vger.kernel.org>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Jens Freimann <jfrei@linux.vnet.ibm.com>,
linux-s390 <linux-s390@vger.kernel.org>,
kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 1/4] KVM: Provide function for VCPU lookup by id
Date: Thu, 19 Nov 2015 12:11:52 +0000 [thread overview]
Message-ID: <564DBC88.5020508@redhat.com> (raw)
In-Reply-To: <1447922251-54261-2-git-send-email-borntraeger@de.ibm.com>
On 19/11/15 09:37, Christian Borntraeger wrote:
> From: David Hildenbrand <dahi@linux.vnet.ibm.com>
>
> Let's provide a function to lookup a VCPU by id.
>
> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reviewed-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> [split patch from refactoring patch]
> ---
> include/linux/kvm_host.h | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index 5706a21..b9f345f 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -460,6 +460,17 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
> (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \
> idx++)
>
> +static inline struct kvm_vcpu *kvm_lookup_vcpu(struct kvm *kvm, int id)
> +{
> + struct kvm_vcpu *vcpu;
> + int i;
> +
> + kvm_for_each_vcpu(i, vcpu, kvm)
> + if (vcpu->vcpu_id = id)
> + return vcpu;
> + return NULL;
> +}
> +
Any chance that you name this function differently? Otherwise we've got
two functions that sound very similar and also have similar prototypes:
- kvm_get_vcpu(struct kvm *kvm, int i)
- kvm_lookup_vcpu(struct kvm *kvm, int id)
I'm pretty sure this will cause confusion in the future!
=> Could you maybe name the new function something like
"kvm_lookup_vcpu_by_id" or "kvm_get_vcpu_by_id" instead?
Also a short comment before the function would be nice to make the
reader aware of the difference (e.g. when hot-plugging) between the
vcpu-id and array-id.
Otherwise: +1 for finally having a proper common function for this!
Thomas
WARNING: multiple messages have this Message-ID (diff)
From: Thomas Huth <thuth@redhat.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Alexander Graf <agraf@suse.de>, Paul Mackerras <paulus@samba.org>,
David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: KVM <kvm@vger.kernel.org>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Jens Freimann <jfrei@linux.vnet.ibm.com>,
linux-s390 <linux-s390@vger.kernel.org>,
kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 1/4] KVM: Provide function for VCPU lookup by id
Date: Thu, 19 Nov 2015 13:11:52 +0100 [thread overview]
Message-ID: <564DBC88.5020508@redhat.com> (raw)
In-Reply-To: <1447922251-54261-2-git-send-email-borntraeger@de.ibm.com>
On 19/11/15 09:37, Christian Borntraeger wrote:
> From: David Hildenbrand <dahi@linux.vnet.ibm.com>
>
> Let's provide a function to lookup a VCPU by id.
>
> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reviewed-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> [split patch from refactoring patch]
> ---
> include/linux/kvm_host.h | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index 5706a21..b9f345f 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -460,6 +460,17 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
> (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \
> idx++)
>
> +static inline struct kvm_vcpu *kvm_lookup_vcpu(struct kvm *kvm, int id)
> +{
> + struct kvm_vcpu *vcpu;
> + int i;
> +
> + kvm_for_each_vcpu(i, vcpu, kvm)
> + if (vcpu->vcpu_id == id)
> + return vcpu;
> + return NULL;
> +}
> +
Any chance that you name this function differently? Otherwise we've got
two functions that sound very similar and also have similar prototypes:
- kvm_get_vcpu(struct kvm *kvm, int i)
- kvm_lookup_vcpu(struct kvm *kvm, int id)
I'm pretty sure this will cause confusion in the future!
==> Could you maybe name the new function something like
"kvm_lookup_vcpu_by_id" or "kvm_get_vcpu_by_id" instead?
Also a short comment before the function would be nice to make the
reader aware of the difference (e.g. when hot-plugging) between the
vcpu-id and array-id.
Otherwise: +1 for finally having a proper common function for this!
Thomas
next prev parent reply other threads:[~2015-11-19 12:11 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-19 8:37 [PATCH 0/4] Preview: vcpu lookup by id changes Christian Borntraeger
2015-11-19 8:37 ` Christian Borntraeger
2015-11-19 8:37 ` [PATCH 1/4] KVM: Provide function for VCPU lookup by id Christian Borntraeger
2015-11-19 8:37 ` Christian Borntraeger
2015-11-19 12:11 ` Thomas Huth [this message]
2015-11-19 12:11 ` Thomas Huth
2015-11-19 12:55 ` David Hildenbrand
2015-11-19 12:55 ` David Hildenbrand
2015-11-19 13:13 ` Paolo Bonzini
2015-11-19 13:13 ` Paolo Bonzini
2015-11-19 13:23 ` Christian Borntraeger
2015-11-19 13:23 ` Christian Borntraeger
2015-11-19 13:36 ` David Hildenbrand
2015-11-19 13:36 ` David Hildenbrand
2015-11-19 8:37 ` [PATCH 2/4] KVM: s390: fix wrong lookup of VCPUs by array index Christian Borntraeger
2015-11-19 8:37 ` Christian Borntraeger
2015-11-19 8:52 ` Christian Borntraeger
2015-11-19 8:52 ` Christian Borntraeger
2015-11-19 8:37 ` [PATCH 3/4] KVM: use heuristic for fast VCPU lookup by id Christian Borntraeger
2015-11-19 8:37 ` Christian Borntraeger
2015-11-19 8:37 ` [PATCH 4/4] KVM: Use common function for " Christian Borntraeger
2015-11-19 8:37 ` Christian Borntraeger
2015-11-19 9:38 ` [PATCH 0/4] Preview: vcpu lookup by id changes Paolo Bonzini
2015-11-19 9:38 ` Paolo Bonzini
2015-11-19 9:51 ` Christian Borntraeger
2015-11-19 9:51 ` Christian Borntraeger
2015-11-19 9:52 ` Paolo Bonzini
2015-11-19 9:52 ` 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=564DBC88.5020508@redhat.com \
--to=thuth@redhat.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=dahi@linux.vnet.ibm.com \
--cc=jfrei@linux.vnet.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=paulus@samba.org \
--cc=pbonzini@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.