Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp340740pxm; Wed, 2 Mar 2022 16:49:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFiNKZzqEes8RWcFQB5xI1f7+DrFWE42djsD2HuP9W1NahvbDgWJOSxVDOqqHZWjoJB/Ch X-Received: by 2002:a17:902:b715:b0:14d:bb53:da0 with SMTP id d21-20020a170902b71500b0014dbb530da0mr33152270pls.18.1646268599006; Wed, 02 Mar 2022 16:49:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646268598; cv=none; d=google.com; s=arc-20160816; b=k73uUsNITRCB985gHvVYKKLy/DpA1tXMPFj9siX/7rSCR41KZx2dLBjUBgEhzlot5O Lt5f80d0RZlr+6cA3IUeLSQUZ9vXtbE6oSgGK7+fMX7z6BjK5fxXfQjzkqRSxSWli8vU TRWSSWrT8TJL8pQspY8RDyoZirRTLaCFSQ8EpXT+HvjO6nkPZ6WRyVoW9IaDbPC5k63+ NqIJ5zS1DD0Y1DbmNv3LyrO/MspAdukErp373Pcj86cbecXx3Y7sT37SsEM2dVCzVL/U uS03tHT3jgtQw46LQP26jSeePJ6/qhn0sR34Ns6bD/ELCjz2/MV/7wfYxgzmnyPEzIqs vRRA== 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=Td4OZ3CGd5qbdkbgU7FY+nlkAv7YQKpmIhrzx/kUjzU=; b=aTbnMiJPEtXIdBDURuByBizRmUg/TdisKbtZTl8xpKzDz3lxbrgBPRX1U1GTy5t905 ExB8b5yji2rQfwDOK3CL3Y8LhzqjP77xHVi0oSwD0Q5LBI1H5rNte1RB7oR1gZYWWi6S qmdCEI5tHiBuXeeNqjJR+4FqOPpU5fRIRzqffL1uuYplqHMsxaaFHPa3iAw2loILUERx KQEzrQ23/wW/2hlete3iIHamRDt3CzvHVjh9h/EZ5DdbswKURI+xr0Bu4m9ZH1tjIGUj Lb+gCH7x7o9/zYNkMWzylTpWBZIqDkYj1Zf9nhcSHZ621EXhpVEpb2e15bQW7YpDKE5n 12bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=K1LcK7iC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m1-20020a639401000000b00372cbbdd8d6si579215pge.637.2022.03.02.16.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 16:49:58 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=K1LcK7iC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A3B7210DA52; Wed, 2 Mar 2022 16:12:46 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230143AbiCCANQ (ORCPT + 99 others); Wed, 2 Mar 2022 19:13:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbiCCANN (ORCPT ); Wed, 2 Mar 2022 19:13:13 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20CE4CB937 for ; Wed, 2 Mar 2022 16:12:30 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id p3-20020a17090a680300b001bbfb9d760eso6243321pjj.2 for ; Wed, 02 Mar 2022 16:12:30 -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=Td4OZ3CGd5qbdkbgU7FY+nlkAv7YQKpmIhrzx/kUjzU=; b=K1LcK7iCnXuheBWswh9IK28RiGD6oNWwq9sVu+D7heKHTJ4ArDuYccdpbxGNoDQ43z rXucgFRTFwpkDDKm5q8FHQlbT0RXSWsJmBRhCeJJSoObX5ISY20k1epb5uXEBQZYsTJb 52fvKPWsR193DmcZ5aAKb8BoscIkjXmPWuQXX/lOKH5RWZMS2BnAJGOEFQpske8qx+Cc dDHOja0t1ObCNHaLze4mbZjXZV1606kGCYyU7SZonkicuaWQhYa0vj0uuzdtryUta6HR WawmlaAyb2plPEIyi/9iw1mS4soHJ7Xj7itbwm1xuWD/cr8F8Bua5JC7QN0AF4OE/GVX ukUw== 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=Td4OZ3CGd5qbdkbgU7FY+nlkAv7YQKpmIhrzx/kUjzU=; b=Iy9b3iNHyDoVhMGenfJ9KYDkAkVXRKW3lSLyGGyPT0Y4YKsrgbvMWro47IKUPladmW Rg0gPPlBKpNIXyBaCvF9YVxrJRZ8WD8h3KPR9LS5rz49PU/nTA/SAdPtZp4oY365MRTy m0jOKgxXrr9NUZDHuXexbRK3iahFh119q9EbByKOWVc0CsyqEFmgOvs/sW4y2lOHpyb5 TULBtfBPWUvdnke3ReVAfgrp74GjaiA7KhfxJ2KGCeFTQLLl9X0abjunvOhF4J5/MWXk tXc7xXvnlbCXLY9DBJK+iCB6VRWnZ+/gnxfNJ+gbSMFsqemoChSgJM8wHsMk1uL42eQq Y+XQ== X-Gm-Message-State: AOAM530WEknaYt0G3F7mN+F0E9SG6ffBYHsSzaZn0b6PZOWPJrD4dCSd hU6JJLvS6q7+vi67eoBYU42TjQ== X-Received: by 2002:a17:90b:3d02:b0:1bc:85fa:e24 with SMTP id pt2-20020a17090b3d0200b001bc85fa0e24mr2354281pjb.239.1646266349430; Wed, 02 Mar 2022 16:12:29 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id y5-20020a056a00180500b004e1bea9c587sm323943pfa.67.2022.03.02.16.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 16:12:28 -0800 (PST) Date: Thu, 3 Mar 2022 00:12:25 +0000 From: Sean Christopherson To: Mingwei Zhang 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 04/28] KVM: x86/mmu: Formalize TDP MMU's (unintended?) deferred TLB flush logic Message-ID: References: <20220226001546.360188-1-seanjc@google.com> <20220226001546.360188-5-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_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 Wed, Mar 02, 2022, Mingwei Zhang wrote: > On Sat, Feb 26, 2022, Sean Christopherson wrote: > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > > index 12866113fb4f..e35bd88d92fd 100644 > > --- a/arch/x86/kvm/mmu/tdp_mmu.c > > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > > @@ -93,7 +93,15 @@ void kvm_tdp_mmu_put_root(struct kvm *kvm, struct kvm_mmu_page *root, > > list_del_rcu(&root->link); > > spin_unlock(&kvm->arch.tdp_mmu_pages_lock); > > > > - zap_gfn_range(kvm, root, 0, -1ull, false, false, shared); > > + /* > > + * A TLB flush is not necessary as KVM performs a local TLB flush when > > + * allocating a new root (see kvm_mmu_load()), and when migrating vCPU > > + * to a different pCPU. Note, the local TLB flush on reuse also > > + * invalidates any paging-structure-cache entries, i.e. TLB entries for > > + * intermediate paging structures, that may be zapped, as such entries > > + * are associated with the ASID on both VMX and SVM. > > + */ > > + (void)zap_gfn_range(kvm, root, 0, -1ull, false, false, shared); > > Understood that we could avoid the TLB flush here. Just curious why the > "(void)" is needed here? Is it for compile time reason? Nope, no functional purpose, though there might be some "advanced" warning or static checkers that care. The "(void)" is to communicate to human readers that the result is intentionally ignored, e.g. to reduce the probability of someone "fixing" the code by acting on the result of zap_gfn_range(). The comment should suffice, but it's nice to have the code be self-documenting as much as possible.