Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6763146rwn; Tue, 13 Sep 2022 08:42:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR7SObb/YkrsAbAff0sovvpVPi39xn9wzcMANl1gpCa20kNWiusTMEedy+n9C1WIArII5KUK X-Received: by 2002:a17:907:2ced:b0:773:6f77:f10f with SMTP id hz13-20020a1709072ced00b007736f77f10fmr19313564ejc.34.1663083729590; Tue, 13 Sep 2022 08:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663083729; cv=none; d=google.com; s=arc-20160816; b=CusHf77v1Bz22uHTjknfRLhtNSspnxSPxGIkMfDPyJnDH3+WJ+I5yZI1CVrC6jOcq8 TWJz6eKHSQCEiSVdINhkSPRxQGmNdqm1obKrX+8bJtEnfsJ4u1+EIo81rCU1ROZLgwcA HsuRcoukQc9LOJoDuUwPqgw/kCidZjsp/kdPhUy3OdJqAlKVJB2W176xiTXEGbF8ZrIl NMnRKy9gzs3RWvljZtjNApY1ipiOUBmlz/aMDvm4Y0uaKOeS/dM8cbUeNksZlLRnA5/w rlP+J8yYO3yFL73L7U6PGhwBz9kAE3xMtm9crE/ddNbg2BLJ+Wuftwgud5VCAmywhnhf kpLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Xz00WUlNoMcvuGzmZoT3YtH17wlzSyS0xFHNgt419Gk=; b=CeLPrP++/wCXf6Y6jJQivVWJN6r8LEFE5ASFmpd1ow3oU0jNdwS36SIObZmS/1Rl1h lxieO+Kpb69y+/Jfni/hJrIkzbaVj7Crg9UOg90PVJ24T5Jbd8sHAhwlA/JIUXYenN8d dp9og6C0iKVQ1ICRw2tpUQuQwBRx6ApqZ+LbRcJU11ZctQvC+QRXRC6K0qEpTQAWWoeI Gy/00Ei3QMYOVmz2zYtGz9HC0FVTdUNRiiKYwARibwUz1I8LtVnr6ZVbaXk4omYdXpMG 4KQ1pcU3A750vaemA5DkOggbuDTKypUU9kI9q1yy3Ii/BVfxcldHdYTCF4J1QiCdJeQg +cQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=lUsjBgil; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16-20020a056402511000b0045093559f1dsi10385681edd.509.2022.09.13.08.41.44; Tue, 13 Sep 2022 08:42:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=lUsjBgil; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231827AbiIMN60 (ORCPT + 99 others); Tue, 13 Sep 2022 09:58:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231866AbiIMN6Y (ORCPT ); Tue, 13 Sep 2022 09:58:24 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9A334DB3D for ; Tue, 13 Sep 2022 06:58:23 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id s10so13851313ljp.5 for ; Tue, 13 Sep 2022 06:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=Xz00WUlNoMcvuGzmZoT3YtH17wlzSyS0xFHNgt419Gk=; b=lUsjBgilev82eRTIjXeALpddVB70OObeUL+rQ+CVv5Xz7/Q4E6xSSEMA+oNJJAKPOe BncPJ1pDrE40RjDYbevpdqqCaVYprSiklIRR89m40RyyKzVkl3z7N0t8REFBPPqGoGf3 IHb2qmPtSxCyptLqs0Y/1OZkm+P71HV8Bpd0JUYGUu7zThDlDWgL+wa488uVapxjXXhs JRzlTL8byDtmXAo5+YgYLRG8qxnYBxI4zfCHdjT5RiCro07MjRhcjw2JSZIJfbQcmIJB 2hd0sWlXmFAFEkUjEhBsFE4Os15LDehHDOpBkXbsZ1aHdUWwySLa8Wf6YH/gWZEN9XOV WScQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=Xz00WUlNoMcvuGzmZoT3YtH17wlzSyS0xFHNgt419Gk=; b=gzTJg5h4yebNFtN1+td4hGeCcsi6FVj1209Ljq0G6yTt6/74d5YsqflDSfCjxtssnx CdkT2CG9Ve33s/QK9O7/xQG9zdPePf4co56eREhiib81h36cYVD3p0i38eW262/F7N8k o9CFx8fYDtpNKKS2zs8t8WmD4v0Rc8f4YT1DfekEJFCwE6VASOq0TXEgC199ywl59l1J 201olz7A5U2aAmIHix0csKZyII3MinEyZHL2NfP28JOl0G7tjy3qQarn9yMF7iPF+QXb V7wrTdO4aTqcjTVE+MLiaAR0XA3Z1F5DZXLKAglSCoz9Ri6DpD8gtbSPf2iRe7nLtLdC EcnA== X-Gm-Message-State: ACgBeo28X/Zr7j8lLviuE8jRDUSLQymj+GkBM1kBw9qbTG8i37ipI9z1 LbGZWqQw8Snd5jD/fhEYWjNezKTrwqhTOosaBpNVzQ== X-Received: by 2002:a2e:87d9:0:b0:26a:ceee:c77b with SMTP id v25-20020a2e87d9000000b0026aceeec77bmr9716521ljj.275.1663077502029; Tue, 13 Sep 2022 06:58:22 -0700 (PDT) MIME-Version: 1.0 References: <8baa40dad8496abb2adb1096e0cf50dcc5f66802.1661331396.git.houwenlong.hwl@antgroup.com> <20220913125833.GC113257@k08j02272.eu95sqa> In-Reply-To: <20220913125833.GC113257@k08j02272.eu95sqa> From: David Matlack Date: Tue, 13 Sep 2022 06:57:55 -0700 Message-ID: Subject: Re: [PATCH v2 6/6] KVM: x86/mmu: Use 1 as the size of gfn range for tlb flushing in FNAME(invlpg)() To: Hou Wenlong Cc: kvm list , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , X86 ML , "H. Peter Anvin" , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 13, 2022 at 5:58 AM Hou Wenlong wrote: > > On Thu, Sep 08, 2022 at 01:40:16AM +0800, David Matlack wrote: > > On Wed, Aug 24, 2022 at 05:29:23PM +0800, Hou Wenlong wrote: > > > Only SP with PG_LEVLE_4K level could be unsync, so the size of gfn range > > > must be 1. > > > > > > Signed-off-by: Hou Wenlong > > > --- > > > arch/x86/kvm/mmu/paging_tmpl.h | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h > > > index 04149c704d5b..486a3163b1e4 100644 > > > --- a/arch/x86/kvm/mmu/paging_tmpl.h > > > +++ b/arch/x86/kvm/mmu/paging_tmpl.h > > > @@ -937,7 +937,8 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva, hpa_t root_hpa) > > > > > > mmu_page_zap_pte(vcpu->kvm, sp, sptep, NULL); > > > if (is_shadow_present_pte(old_spte)) > > > - kvm_flush_remote_tlbs_sptep(vcpu->kvm, sptep); > > > + kvm_flush_remote_tlbs_gfn(vcpu->kvm, > > > + kvm_mmu_page_get_gfn(sp, sptep - sp->spt), 1); > > > > The third argument to kvm_flush_remote_tlbs_gfn() is the level, not the > > number of pages. But that aside, I don't understand why this patch is > > necessary. kvm_flush_remote_tlbs_sptep() should already do the right > > thing. > > > Since only SP with PG_LEVEL_4K level could be unsync, so the level must > be PG_LEVEL_4K, then sp->role.level access could be dropped. However, > I'm not sure whether it is useful. I can drop it if it is useless. Ah, I see. I would be surprised if avoiding the read of sp->role.level has any noticeable impact on VM performance so I vote to drop this patch. > > > > > > > if (!rmap_can_add(vcpu)) > > > break; > > > -- > > > 2.31.1 > > >