LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] KVM: x86: Identify vCPU0 by its vcpu_idx instead of walking vCPUs array
Date: Wed, 22 Sep 2021 09:41:12 +0200	[thread overview]
Message-ID: <c12a4ef0-5b20-a81a-26bd-7d29c59ece8d@redhat.com> (raw)
In-Reply-To: <YUihS9CcTh9m53J6@google.com>

On 20/09/21 16:57, Sean Christopherson wrote:
> On Mon, Sep 13, 2021, Vitaly Kuznetsov wrote:
>> Sean Christopherson <seanjc@google.com> writes:
>>
>>> Use vcpu_idx to identify vCPU0 when updating HyperV's TSC page, which is
>>> shared by all vCPUs and "owned" by vCPU0 (because vCPU0 is the only vCPU
>>> that's guaranteed to exist).  Using kvm_get_vcpu() to find vCPU works,
>>> but it's a rather odd and suboptimal method to check the index of a given
>>> vCPU.
>>>
>>> No functional change intended.
>>>
>>> Signed-off-by: Sean Christopherson <seanjc@google.com>
>>> ---
>>>   arch/x86/kvm/x86.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>>> index 86539c1686fa..6ab851df08d1 100644
>>> --- a/arch/x86/kvm/x86.c
>>> +++ b/arch/x86/kvm/x86.c
>>> @@ -2969,7 +2969,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
>>>   				       offsetof(struct compat_vcpu_info, time));
>>>   	if (vcpu->xen.vcpu_time_info_set)
>>>   		kvm_setup_pvclock_page(v, &vcpu->xen.vcpu_time_info_cache, 0);
>>> -	if (v == kvm_get_vcpu(v->kvm, 0))
>>> +	if (!v->vcpu_idx)
>>>   		kvm_hv_setup_tsc_page(v->kvm, &vcpu->hv_clock);
>>>   	return 0;
>>>   }
>>
>> " ... instead of walking vCPUs array" in the Subject line is a bit
>> confusing because kvm_get_vcpu() doesn't actually walk anything, it just
>> returns 'kvm->vcpus[i]' after checking that we actually have that many
>> vCPUs. The patch itself is OK, so
> 
> Argh, yes, I have a feeling I wrote the changelog after digging into the history
> of kvm_get_vcpu().
> 
> Paolo, can you tweak the shortlog to:
> 
>    KVM: x86: Identify vCPU0 by its vcpu_idx instead of its vCPUs array entry
> 

Done and queued.  Patch 1 required some further s390 changes.

Paolo


      reply	other threads:[~2021-09-22  7:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 18:32 [PATCH 0/2] KVM: x86: vcpu_idx related cleanups Sean Christopherson
2021-09-10 18:32 ` [PATCH 1/2] KVM: x86: Query vcpu->vcpu_idx directly and drop its accessor Sean Christopherson
2021-09-12 10:49   ` Maxim Levitsky
2021-09-13  7:02   ` Vitaly Kuznetsov
2021-09-10 18:32 ` [PATCH 2/2] KVM: x86: Identify vCPU0 by its vcpu_idx instead of walking vCPUs array Sean Christopherson
2021-09-10 21:46   ` Jim Mattson
2021-09-12 10:52   ` Maxim Levitsky
2021-09-13  7:07   ` Vitaly Kuznetsov
2021-09-20 14:57     ` Sean Christopherson
2021-09-22  7:41       ` Paolo Bonzini [this message]

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=c12a4ef0-5b20-a81a-26bd-7d29c59ece8d@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --subject='Re: [PATCH 2/2] KVM: x86: Identify vCPU0 by its vcpu_idx instead of walking vCPUs array' \
    /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

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).