Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp959177pxb; Sun, 12 Sep 2021 03:56:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaAAsKhqXNBJ0Hj8H8gAJEhJuRKW4hnxHWoc6J/vlTOiHH1Sz7jN1KWj2ZLiSYduAU/CY+ X-Received: by 2002:a17:906:4c89:: with SMTP id q9mr7131832eju.118.1631444167942; Sun, 12 Sep 2021 03:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631444167; cv=none; d=google.com; s=arc-20160816; b=NfcnDuTvQULeeasL8j4Q8Gy4IypiSXITA/zFNYDZ07UsFJfhlJdidwkXmnatFrq6vo TPPbMBPOXPwVomW+waVU2/qC22IcFq5zL/ws2MYPTZ6kXbfF9wRdm6Cb4NuTbpoV0Sa1 qiIkGruINHCrwipjp+cqJHJlubWGwgk5UdV7xyIXiFsK1rsKxs43LMy65ObfgaBDKXRb oOsZi4j089T7B/iT7cYYwESNRa+SQjLjlIFAFlc31LwJF0DyWK06eln2koSkeq6fgl7T t15IXySYXgztFFYWkYuc5M5PGjSKmYMePFS/rfnFCZcdpX5W6BEZPe0lgAHypueRNMhv 1QtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=yDakpUmSFyXjuIlV4mL/N0HP20GQTBep5L0kF3rwf+E=; b=Cw2Ow0xqAIl/6rJCiJY+TqYxv7+B1LZD9fWfLvv3XByROyAtOTgNRsZI5kmoMStH3g 9iyvv/AbvYA2WUm5/oY1AyGB/81SyKtbIX/HexzBD5sgfEpbCScs9SnkmUWc6s8lea7f yzloT6jjnjT3Qi4j2GJYstqitpnBIz30itha623QxZSLW/TzPp7+lMmE7VakExd4Dom4 lq4H+Bog6E9v8apYqfCupHjnxC/dWLV67cCr/TvqmZFsj96TPusqJDSPNhc8nCsHN328 kgFeXJRic+w4HbvU29DioYIN3uOgROoEtm8CT2mMnvwQLzP/F4BVhK13jrck4lZO1q1o 9ZVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PJyFfPSf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y21si4502428eds.53.2021.09.12.03.55.43; Sun, 12 Sep 2021 03:56:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PJyFfPSf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233355AbhILKyF (ORCPT + 99 others); Sun, 12 Sep 2021 06:54:05 -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