From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52F22C433F5 for ; Sun, 12 Sep 2021 10:52:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3267261211 for ; Sun, 12 Sep 2021 10:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233678AbhILKyG (ORCPT ); Sun, 12 Sep 2021 06:54:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35760 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbhILKyF (ORCPT ); Sun, 12 Sep 2021 06:54:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631443971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yDakpUmSFyXjuIlV4mL/N0HP20GQTBep5L0kF3rwf+E=; b=PJyFfPSf1LahHqf8PB1tCVa6h8oVGevisQrrejrVQ6S3SSWT7ArIr29JxcQ1puxHyIEfRY doWkSr4OGrLYm4PCaygvslAQk7/EAPsUeb0wczzC1QLLFpMcOwbsEqLlT83eYDtdakARXa gM3VWgJceQEv3VwOAbYGS9VSdwm2jCs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-114-LKrH9b1dNC25uY-OaPMMww-1; Sun, 12 Sep 2021 06:52:48 -0400 X-MC-Unique: LKrH9b1dNC25uY-OaPMMww-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C7205801B3D; Sun, 12 Sep 2021 10:52:46 +0000 (UTC) Received: from starship (unknown [10.35.206.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA8FB5D9D5; Sun, 12 Sep 2021 10:52:44 +0000 (UTC) Message-ID: <71a6464fa0bca675e079f6171296ff5f63cab05c.camel@redhat.com> Subject: Re: [PATCH 2/2] KVM: x86: Identify vCPU0 by its vcpu_idx instead of walking vCPUs array From: Maxim Levitsky To: Sean Christopherson , Paolo Bonzini Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sun, 12 Sep 2021 13:52:43 +0300 In-Reply-To: <20210910183220.2397812-3-seanjc@google.com> References: <20210910183220.2397812-1-seanjc@google.com> <20210910183220.2397812-3-seanjc@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-09-10 at 11:32 -0700, Sean Christopherson wrote: > 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 > --- > 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; > } Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky