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 6DB9EC433F5 for ; Thu, 3 Mar 2022 18:51:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235827AbiCCSvx (ORCPT ); Thu, 3 Mar 2022 13:51:53 -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-Google-Smtp-Source: ABdhPJxX8XR0ZS0cRvllspUQlxpTdJW88rG6/kheSbKjyDIs1IbwHSUjG1b1J56o0sqgIeYukK3btw== 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> 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 >