Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1168133pxm; Thu, 3 Mar 2022 11:40:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcdOw9Z5CAIpRoIFw60GFR2tDfR5wIWoFkkuDvI2unj0zxDsIdQiso6oa4tSwC6ngwn9py X-Received: by 2002:a17:907:9703:b0:6da:6412:508a with SMTP id jg3-20020a170907970300b006da6412508amr7754404ejc.77.1646336405134; Thu, 03 Mar 2022 11:40:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646336405; cv=none; d=google.com; s=arc-20160816; b=eK/xsOSh+Rc9vSO3F8vUQKg5YQVqtqymX+6CC0HNK8RF+M5XiL418YqZW7+gfB0h3T VZLfXA/7Y/hJUuDgLO+bSWYEAkGHmzllN5nnntvAh3pbV8VGElX7zpzqix6NcK+wY1EQ sumTz7ZQ7MOFpNSDPjfnxne8BXLxZ8ohBOP8ghpiV4vubZOE1vnXKE3yjAnwXcVNrQim 0r2mx4v+a74zIkD2zIDk6nSgXNLlvXd1G3UoQllO8VUjHeb5ausD81zoyVEkvt/F0CVR TPwmb8imI1ehmjs2hLsNBz5OSAyoe8BdkdXLvjK5/mnAZ9Zvu3zbnHj5lp5QgNnm7mH1 N9ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yX5m8MlUOAzLqKBbT/pjod3RHno71P9LV7MCNSMdCNA=; b=lWQ0eF3abbIWTTlwTA/b1g7z4Wmiwmc5IWeGeABB4p5a/DvftrZV+4XvUXTAG90nP7 sAXudsmfBM8qeU41fAasv+3vYfz1vvfXhT43pUg9+Ey6vvODFAY9h9F5RMoxnqNIVqIN QtAu/N6UyDlSfIdjBC/dV2lYO2VUnT/025og53SOR/a9bVgGn2jpigGEnX8Whoceu11Z SfeckYMep3i+32gxJ4SRjhKBrhqAMRrAmmk4WA8N+Wyfzn/7tb2K59mjg69L6jrSsp/h lfFMuEWqN+qX7IL728nAWd3coF9gRBSEpb+GUQQHiLeVpLkUzdfXypHGSGnYkkOsA0Gt Yv0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hKByNygA; 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 g26-20020a50d0da000000b00412f4d8fa7fsi2190787edf.124.2022.03.03.11.39.41; Thu, 03 Mar 2022 11:40:05 -0800 (PST) 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=hKByNygA; 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 S235821AbiCCSvv (ORCPT + 99 others); Thu, 3 Mar 2022 13:51:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235726AbiCCSvt (ORCPT ); Thu, 3 Mar 2022 13:51:49 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79A1119CCE5 for ; Thu, 3 Mar 2022 10:51:03 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id gb21so5357013pjb.5 for ; Thu, 03 Mar 2022 10:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yX5m8MlUOAzLqKBbT/pjod3RHno71P9LV7MCNSMdCNA=; b=hKByNygA1xInTtaOkprgwYnnSAvv3TOfL1VRe9RsQUpBLFx1/c6vMaTN8ywDq1jd0r S9+BNhV687ksiIgKNgFtooC6ZfYgYyYjj9Lqu6SjcSriUIcS4CwvlaQBFt8RNkUPKjhb A5xPtVw21RU9INzaevBV/emcaNy0Tdh1nFpL+hw4YPJ8G/kUVo0x748Pk7jy/gVrVMgl Vb4a7HKm7QPShHMiUOfKj7gkpuTBuZ9c9GdwKZQpH9tOn10s1dnuQ0gFegSVcDKUADES Fl0TdlH+N9GRSQV+TZGZzAzN0gtePMTI0jmbpKyQNv2IbHGCrHGlxD2+ylk/DUgy68/9 mz8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yX5m8MlUOAzLqKBbT/pjod3RHno71P9LV7MCNSMdCNA=; b=vlwjVse6fWnRJSSTBDqVZ52FoYV90VbM0qNjayaj8hT9bMzTONezaPY9apOij3qDcl A3ycLwc0rX96EXPqxdaoDBKj+MLoyFzgOkBY8oY+aoaI8SUV0Tnjo38A2+gYcei+N0+l TZEyH7UDTJSZfst2tbQpjOmD4QGqr5jmRrKkQ1Y24gCgs3Nr7kf0AxqY5wYdTPoqfVGi DowpxcUpcSyDFjMHlrqlMpahMqCzZk8PgeOGG/kvAqTnokEq5WaX3ikLU2oqteIvXgdy 2Ac46jUjeCycvqhdA3TsrJXTiHt+tHFP3bRMX4BL5HXHGmbs452Hu6X2wDaO1wyxlSB9 ZfQw== X-Gm-Message-State: AOAM532E0tw+n5Oor2Cz1j7/Z9ycf8CgoJ/SW7+eEpgtR8PQoC6dcEEk eriJKn75GBR1JGBFUuoZyOTr6v2HwuaC5KIt X-Received: by 2002:a17:902:eb8b:b0:151:60f4:84e5 with SMTP id q11-20020a170902eb8b00b0015160f484e5mr24432716plg.134.1646333462795; Thu, 03 Mar 2022 10:51:02 -0800 (PST) Received: from google.com (226.75.127.34.bc.googleusercontent.com. [34.127.75.226]) by smtp.gmail.com with ESMTPSA id k62-20020a17090a4cc400b001bf0d92e1c7sm2704686pjh.41.2022.03.03.10.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 10:51:02 -0800 (PST) Date: Thu, 3 Mar 2022 18:50:58 +0000 From: Mingwei Zhang To: Sean Christopherson Cc: Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Ben Gardon Subject: Re: [PATCH v3 14/28] KVM: x86/mmu: Skip remote TLB flush when zapping all of TDP MMU Message-ID: References: <20220226001546.360188-1-seanjc@google.com> <20220226001546.360188-15-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220226001546.360188-15-seanjc@google.com> X-Spam-Status: No, score=-18.1 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 Sat, Feb 26, 2022, Sean Christopherson wrote: > Don't flush the TLBs when zapping all TDP MMU pages, as the only time KVM > uses the slow version of "zap everything" is when the VM is being > destroyed or the owning mm has exited. In either case, KVM_RUN is > unreachable for the VM, i.e. the guest TLB entries cannot be consumed. > > Signed-off-by: Sean Christopherson Reviewed-by: Mingwei Zhang > --- > arch/x86/kvm/mmu/tdp_mmu.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index c231b60e1726..87706e9cc6f3 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -874,14 +874,15 @@ bool __kvm_tdp_mmu_zap_gfn_range(struct kvm *kvm, int as_id, gfn_t start, > > void kvm_tdp_mmu_zap_all(struct kvm *kvm) > { > - bool flush = false; > int i; > > + /* > + * A TLB flush is unnecessary, KVM zaps everything if and only the VM > + * is being destroyed or the userspace VMM has exited. In both cases, > + * KVM_RUN is unreachable, i.e. no vCPUs will ever service the request. > + */ > for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) > - flush = kvm_tdp_mmu_zap_gfn_range(kvm, i, 0, -1ull, flush); > - > - if (flush) > - kvm_flush_remote_tlbs(kvm); > + (void)kvm_tdp_mmu_zap_gfn_range(kvm, i, 0, -1ull, false); > } > > /* > -- > 2.35.1.574.g5d30c73bfb-goog >