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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25F6EE92712 for ; Thu, 5 Oct 2023 14:42:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237039AbjJEOmZ (ORCPT ); Thu, 5 Oct 2023 10:42:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237035AbjJEOhy (ORCPT ); Thu, 5 Oct 2023 10:37:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E5A54F6FE for ; Thu, 5 Oct 2023 07:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696514482; 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=eB/s9Y6w4YeBVavpvimiNB3pmiRKF4zEjUazPrN+Ua0=; b=UyzrTGH8BWwbVjcM0DunBnfO6iCEFNDgLrvNgR1665PPPY+AxPjzBc3TPtry6dI2OpvpC2 p7NGUIJF4LPZWyXPMWLbH9rUA2pxVCVQINluRvYcVj/bZvoN2VYG6ZeXj875t+JPrrO8Ir BoWsL2i4l8RKJSCZ11UxzF30MoCWU+w= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-218-cW2HcnPaNmGIeC8Q3MwCcg-1; Thu, 05 Oct 2023 08:59:46 -0400 X-MC-Unique: cW2HcnPaNmGIeC8Q3MwCcg-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-323306960e3so678256f8f.1 for ; Thu, 05 Oct 2023 05:59:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696510785; x=1697115585; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=eB/s9Y6w4YeBVavpvimiNB3pmiRKF4zEjUazPrN+Ua0=; b=pzqHvS8Owlwy4zIQhRJokIo+HnWJrgn5MtyL9BzLfySDoUNMNoQYKXAdBjrmsLvNL4 pVGh1RXdx5pArhCAn4rXSHhDOsrik/QOd8bI2/sUlELypteTf5NKBmZT6ur1PkpSD5Vd Zloou4E0ywrevf8/EL4vX0VAFmOkBndkYmia7cd+zU8gd5FNxhvGA/shoAotwkbZ6ni4 Quc8fgc0DTkkuaPtr7tHHw4a7ANAfb+MDXDNtGYIUFomFS+XQhMdgWoV8KtDwpp0jD0I clqlpOrAk/To6AN64890z4Zde3pX1q5vINSSmCJw3NQQFp/U1hQQTtWpQ0Yq2b3592j6 J/gA== X-Gm-Message-State: AOJu0YyXN/Ts7Q0wiJfjPoaV3GVhnwr+e/h7hSxvY4vV8ryfsu/HraOT qtcuuTBS8+fl5ychHYeJaDxpBF+DMPejNjfiW6PvFadwjHj2HH2/FHrwxajLGY0ehFNK6DM+cEm bHn3v24yMcRa+ahAVZgO7kVkG X-Received: by 2002:adf:cd0a:0:b0:31f:f72c:df95 with SMTP id w10-20020adfcd0a000000b0031ff72cdf95mr4843464wrm.21.1696510785515; Thu, 05 Oct 2023 05:59:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvEI5pQfZk4ZhyDAwt1LECiXblBVoH3ImmjiThxEXrj19IR2Tsvu0M7XCB7fYKnjR2dSYpvA== X-Received: by 2002:adf:cd0a:0:b0:31f:f72c:df95 with SMTP id w10-20020adfcd0a000000b0031ff72cdf95mr4843445wrm.21.1696510785139; Thu, 05 Oct 2023 05:59:45 -0700 (PDT) Received: from starship ([89.237.100.246]) by smtp.gmail.com with ESMTPSA id z2-20020a5d6542000000b003196b1bb528sm1752733wrv.64.2023.10.05.05.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 05:59:44 -0700 (PDT) Message-ID: Subject: Re: [PATCH 10/10] KVM: SVM: Rename "avic_physical_id_cache" to "avic_physical_id_entry" From: Maxim Levitsky To: Sean Christopherson , Paolo Bonzini , Joerg Roedel Cc: kvm@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Date: Thu, 05 Oct 2023 15:59:43 +0300 In-Reply-To: <20230815213533.548732-11-seanjc@google.com> References: <20230815213533.548732-1-seanjc@google.com> <20230815213533.548732-11-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: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org У вт, 2023-08-15 у 14:35 -0700, Sean Christopherson пише: > Rename the vCPU's pointer to its AVIC Physical ID entry from "cache" to > "entry". While the field technically caches the result of the pointer > calculation, it's all too easy to misinterpret the name and think that > the field somehow caches the _data_ in the table. I also strongly dislike the 'avic_physical_id_cache', but if you are refactoring it, IMHO the 'avic_physical_id_entry' is just as confusing since its a pointer to an entry and not the entry itself. At least a comment to explain where this pointer points, or maybe (not sure) drop the avic_physical_id_cache completely and calculate it every time (I doubt that there is any perf loss due to this) Best regards, Maxim Levitsky > > No functional change intended. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/svm/avic.c | 10 +++++----- > arch/x86/kvm/svm/svm.h | 2 +- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c > index 6803e2d7bc22..8d162ff83aa8 100644 > --- a/arch/x86/kvm/svm/avic.c > +++ b/arch/x86/kvm/svm/avic.c > @@ -310,7 +310,7 @@ static int avic_init_backing_page(struct kvm_vcpu *vcpu) > AVIC_PHYSICAL_ID_ENTRY_VALID_MASK; > WRITE_ONCE(table[id], new_entry); > > - svm->avic_physical_id_cache = &table[id]; > + svm->avic_physical_id_entry = &table[id]; > > return 0; > } > @@ -1028,14 +1028,14 @@ void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > if (kvm_vcpu_is_blocking(vcpu)) > return; > > - entry = READ_ONCE(*(svm->avic_physical_id_cache)); > + entry = READ_ONCE(*(svm->avic_physical_id_entry)); > WARN_ON_ONCE(entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK); > > entry &= ~AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK; > entry |= (h_physical_id & AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK); > entry |= AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK; > > - WRITE_ONCE(*(svm->avic_physical_id_cache), entry); > + WRITE_ONCE(*(svm->avic_physical_id_entry), entry); > avic_update_iommu_vcpu_affinity(vcpu, h_physical_id, true); > } > > @@ -1046,7 +1046,7 @@ void avic_vcpu_put(struct kvm_vcpu *vcpu) > > lockdep_assert_preemption_disabled(); > > - entry = READ_ONCE(*(svm->avic_physical_id_cache)); > + entry = READ_ONCE(*(svm->avic_physical_id_entry)); > > /* Nothing to do if IsRunning == '0' due to vCPU blocking. */ > if (!(entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK)) > @@ -1055,7 +1055,7 @@ void avic_vcpu_put(struct kvm_vcpu *vcpu) > avic_update_iommu_vcpu_affinity(vcpu, -1, 0); > > entry &= ~AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK; > - WRITE_ONCE(*(svm->avic_physical_id_cache), entry); > + WRITE_ONCE(*(svm->avic_physical_id_entry), entry); > } > > void avic_refresh_virtual_apic_mode(struct kvm_vcpu *vcpu) > diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h > index 8b798982e5d0..4362048493d1 100644 > --- a/arch/x86/kvm/svm/svm.h > +++ b/arch/x86/kvm/svm/svm.h > @@ -261,7 +261,7 @@ struct vcpu_svm { > > u32 ldr_reg; > u32 dfr_reg; > - u64 *avic_physical_id_cache; > + u64 *avic_physical_id_entry; > > /* > * Per-vcpu list of struct amd_svm_iommu_ir: