Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3528914pxm; Mon, 28 Feb 2022 23:26:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+jygSKUEqeA4BKMgA+1y9yHMFHe7OHQaIDPlcSZfghczK3D3pkcFcKHoAn1vzRS8NVCdn X-Received: by 2002:a17:902:c7c9:b0:14f:b5fb:cf1b with SMTP id r9-20020a170902c7c900b0014fb5fbcf1bmr24768809pla.14.1646119603691; Mon, 28 Feb 2022 23:26:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646119603; cv=none; d=google.com; s=arc-20160816; b=W8awFnSMI8TuHAIJPJ0GBX5Gk3UN2Nbcsnf4h5NpGNiTR7a6lNt5MSHLhIo4D7D6+G fvhxmsOYa4eJjKtQFrCyES9dxOQllEH9+b0iM9Usw35W6CIktjkuCszwqHCtcR6iZeZY 8f6BR7IV21MDPvnMwf2febMRYmhcSHDIVuEU4WoH3zyBYE9Xere7X3uwfqCBlR6Y+UKq IXH3t4W1Tgnq2oZIsXMf+0hBroeArQ0tsG8DWWbZtl5sughJnVK7C5YKrTBjzG5YBn6z gaB+enPpNjR8Pz5Lg+5qI2Aga3eUgbA2+3dfyUcS9Hdoqkc7iHdrTzs+9pHSnu+Odx5a ZfBA== 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=dQJGpmwFtFwNXc5097mgkIYQwk2uZL35ska8T+NcJow=; b=ARVjYFrEgBdzdbOaJ31GWKoIjTZynEPk9eOi+GhHbq0iR35mVxmkr60OrvuJG+lZWD Srq6QZvqJmoH3kBuo5Mu2BO0Ernsj5YCKxQ23VUxOmuxgnJHg7hbHVI0ZgZ3nUi9j+gx nXrl+rtIItA7z2wQO2l6a7jurjzmzS48UCNkFTfiSGWlmOk9LXj/LNJOo85aDQe2eytN IPu9QP3/LI7NAGHZ8YliNYvo+b7n+/TaRwiGVVH6RffRLbfv2jqGsJquVD/EY3R5Tb4H o3wSnDgLIHwz6k/qSSuAhKM4Ry/ynkNPQAnO8fwNkW4NZzSWcg58cHClE1zNJmLMPyd5 0iQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=KGs+vZGM; 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 h192-20020a636cc9000000b00372eb3a9c8fsi10622119pgc.138.2022.02.28.23.26.28; Mon, 28 Feb 2022 23:26:43 -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=KGs+vZGM; 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 S231636AbiCAAUi (ORCPT + 99 others); Mon, 28 Feb 2022 19:20:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231205AbiCAAUh (ORCPT ); Mon, 28 Feb 2022 19:20:37 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F56C24F16 for ; Mon, 28 Feb 2022 16:19:57 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id q17so19874456edd.4 for ; Mon, 28 Feb 2022 16:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dQJGpmwFtFwNXc5097mgkIYQwk2uZL35ska8T+NcJow=; b=KGs+vZGMy5o9gCgPNjwPwkknTqUWH9d0S8bb/zRio2fK8Dv2rghQHeRb0KEjWTL766 2eIDXGI5icCSPszRCMqnEqI+Ha1KfrCWpoKB6bcg2eFOwWSpydNvr466GcYTP26Qg4/f tARKJddn0pc3oXyPqf7e2kZhmrBDolzHBC6A3OZd+t+PvBtzkjeZK8qyG1jh7nHP3u1p J9gr4HZL/3Kst9h2MP4Dg4o46b86zGUY/caqwKWf+zElIuBnRV0U2M9wprxl/qaPdjBo IKyHzc3dSqsD21R/j6kvXuEL0gGMs20crzxMIkCYT/GjtIVhwUQsjzlX0uyoKc/veH4H pcbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dQJGpmwFtFwNXc5097mgkIYQwk2uZL35ska8T+NcJow=; b=4CrOYKFACy+ReftOxdQKB2ZkntbHM8DJhn1hHYm1mTmkCX/aZKI+Z+Ohb7z1Yuze+F OLBqeLl8hjCxrnFy98tU+X8IFifYKX0hiJAjS9KXFXC6B5oMm5UJTt7GYuu8h/ruKYTm XN4tPVyqwd16v/iJaqo/4swztREJMaNFsg79USBhR/t6tBIIiTfsn+Ih52cwymU3s0pA Cm5MBFVTLRULYY+jWe2syFCmVP87ivrtaoMHcOVNK01in0kSwFl+2RI9+qoVF6ZBjr2k ui79QoU2TlG7QLJEkcOF4xWCXMV/UwPhaApBiZ5f7figbdAtyASnb8Xkb+0jkC2S/qt1 5tsQ== X-Gm-Message-State: AOAM533SFhEGIfIlXyCuNCqcxjF84TTAigVbKxWD2tFJzrZgE1gtNRKc Zizl2cFGzSxSEv+BjmTKbvQG3U/3kSWweWJy6tgixA== X-Received: by 2002:aa7:c982:0:b0:406:3862:a717 with SMTP id c2-20020aa7c982000000b004063862a717mr22163022edt.358.1646093995992; Mon, 28 Feb 2022 16:19:55 -0800 (PST) MIME-Version: 1.0 References: <20220226001546.360188-1-seanjc@google.com> <20220226001546.360188-15-seanjc@google.com> In-Reply-To: <20220226001546.360188-15-seanjc@google.com> From: Ben Gardon Date: Mon, 28 Feb 2022 16:19:44 -0800 Message-ID: Subject: Re: [PATCH v3 14/28] KVM: x86/mmu: Skip remote TLB flush when zapping all of TDP MMU To: Sean Christopherson Cc: Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , David Hildenbrand , kvm , LKML , David Matlack , Mingwei Zhang Content-Type: text/plain; charset="UTF-8" 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=unavailable 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 Fri, Feb 25, 2022 at 4:16 PM 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: Ben Gardon > --- > 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 >