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 X-Spam-Level: X-Spam-Status: No, score=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB95EC43460 for ; Wed, 31 Mar 2021 22:28:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5CFE61008 for ; Wed, 31 Mar 2021 22:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232662AbhCaW1s (ORCPT ); Wed, 31 Mar 2021 18:27:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232493AbhCaW1f (ORCPT ); Wed, 31 Mar 2021 18:27:35 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1286C061574 for ; Wed, 31 Mar 2021 15:27:35 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id x26so71679pfn.0 for ; Wed, 31 Mar 2021 15:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WpLA/8+oNDyuMS3mRjh7CIaKNZs3vVlk+cUQzEEw+V0=; b=rSblG82rx/HZ2AiRUDoBIpQUlWfYIRlhssFYQBQP3Rf4waNr1zlMADu9Yc7DIMqk45 eZzdBd+QD0SBjyUPJbkAakPUoVu+xKWadHTrDjKulfRheuEXsn1PZuO08QRDCGGbDoNB 8d5hJghzXoYOC1CCSCgUC8g/C2wxb0v0yaZWai+R8LVzfzO+T8X8s118gAFgNRKJMWA3 zEMzpqAX6HQ4LYpAeHc6KVW3UVBdoYL3oUYwruEPAw4UWDpBzFvKPHCkBX95emRe1an8 5/DIHIXxdxhtbL+KR0mj0NaofnhgrrpUVFk2VsFdEy4p9x1OVkV7cR9EA3C2xXNSXIMY nKKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WpLA/8+oNDyuMS3mRjh7CIaKNZs3vVlk+cUQzEEw+V0=; b=Vj6BoxphO/Si8AXGOcV4HfTmjzgXGJkGRVoRGSeKWB0KYdpXJqiunKDu52RsWTR8da shg7E5zz0S5bkUJsH1QdE0JQoBe1qd3+XJpzB7sjad67BozuJTA7lmamwcm6I5gTvO7k iVkd920rDerw3VehavRilOuJW+b4fkOWAtb4KU0GlZ9ieDeToPsP9xT6T+buiR91dILK wkk/X9gs9EcVjuOCj7kp28PaHqs9mTARDIrENruid2N4liUhcNX/n2Nrf/+2CUtVHqwp n4Ay/eNR+Cghx/GHs1U5xW92ifWoFejqq3IphylqI+u7zBsAdqdjOw44Q7X048aFKVuO TYWA== X-Gm-Message-State: AOAM530PQV9Lv95fxdY77lRpSav6ULNDEzxcGGYMduFJtEVV/Ei7N9HC 3Z245pTNp36TiNbCXHQdLz2E8A== X-Google-Smtp-Source: ABdhPJz/NNSLb+31u+PTD2jSbK2k/r80/7e6SA3cFJYq2N69TCi83el/dCjQj51hSg3AXxUO0r5Dqw== X-Received: by 2002:a63:d43:: with SMTP id 3mr5029669pgn.5.1617229655137; Wed, 31 Mar 2021 15:27:35 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id ds3sm3120454pjb.23.2021.03.31.15.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 15:27:34 -0700 (PDT) Date: Wed, 31 Mar 2021 22:27:30 +0000 From: Sean Christopherson To: Ben Gardon Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Peter Xu , Peter Shier , Peter Feiner , Junaid Shahid , Jim Mattson , Yulei Zhang , Wanpeng Li , Vitaly Kuznetsov , Xiao Guangrong Subject: Re: [PATCH 12/13] KVM: x86/mmu: Fast invalidation for TDP MMU Message-ID: References: <20210331210841.3996155-1-bgardon@google.com> <20210331210841.3996155-13-bgardon@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210331210841.3996155-13-bgardon@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 31, 2021, Ben Gardon wrote: > Provide a real mechanism for fast invalidation by marking roots as > invalid so that their reference count will quickly fall to zero > and they will be torn down. > > One negative side affect of this approach is that a vCPU thread will > likely drop the last reference to a root and be saddled with the work of > tearing down an entire paging structure. This issue will be resolved in > a later commit. > > Signed-off-by: Ben Gardon > --- ... > +/* > + * This function depends on running in the same MMU lock cirical section as > + * kvm_reload_remote_mmus. Since this is in the same critical section, no new > + * roots will be created between this function and the MMU reload signals > + * being sent. Eww. That goes beyond just adding a lockdep assertion here. I know you want to isolate the TDP MMU as much as possible, but this really feels like it should be open coded in kvm_mmu_zap_all_fast(). And assuming this lands after as_id is added to for_each_tdp_mmu_root(), it's probably easier to open code anyways, e.g. use list_for_each_entry() directly instead of bouncing through an iterator. > + */ > +void kvm_tdp_mmu_invalidate_roots(struct kvm *kvm) > +{ > + struct kvm_mmu_page *root; > + > + for_each_tdp_mmu_root(kvm, root) > + root->role.invalid = true; > +}