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 A8AC8C43460 for ; Thu, 1 Apr 2021 18:02:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C37C6112F for ; Thu, 1 Apr 2021 18:02:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236444AbhDASC0 (ORCPT ); Thu, 1 Apr 2021 14:02:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236744AbhDARrT (ORCPT ); Thu, 1 Apr 2021 13:47:19 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46C24C03115E for ; Thu, 1 Apr 2021 09:50:21 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id j16so2550531ilq.13 for ; Thu, 01 Apr 2021 09:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0w+zGLeMzdcB8Xl8lhep34DyBJozrhHS5e3zByXXsOs=; b=kDL/vWg/Yf17Di0EMzIUc6FTgS3eEoyakAdcYbqSWhng1EWqEv0beBVyXtY4oMNxaT N/Pybyl9KFbE5JHW15B9s2JAfmLpaETxhpwtABnrRLesdkJB2k/93y6hre3CvjPCLfUt Tdkll+aURgcxmO+zKx5lfF1YibCZ/hWW/H1MVFume13yOjQqD3JfrTrsyDpw5S+z417O B866pKBWyfTSwcB6LBN6YRPRzxQRne1JjhFvH372zxhUSmvNg4Vk4dPUgVGlyDIOvtP1 fMilIuY0gUCwtkcqWF2QTzpaF1YtaaJwLCxzN9lEB4gbAnjTIcmnWfWb5r/XL4GjXdPW CxBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0w+zGLeMzdcB8Xl8lhep34DyBJozrhHS5e3zByXXsOs=; b=D8sk4HbCgUSxlBAQcqIEf8GFGNXJ4SGpG+8qRCFMuPVzmIpGjLd9JjCw7Zq552Rql0 91W6t2PHFesz6NQa51dX2KsEoGC5gOZ69k6fxiYSc0j+6VDCohC61BuprhaIDUdc25NN sVmueTwxDMbi/q+zK/26U2sM5CS76AkV2DBhLn8IqIXkRC7ICVFkFlTS9MYjgZK4XP8Y czWStJ7gEpLG8/JHCldcHvt5Xqx3GDJJ38O8QLhpqRqiyjfTbtoKZehub4Dy8vqrPVJ9 n7nicCcMekGf5Q6hCoHwU35NGLVLx98DqHYWT6LmDjsu/QNPjBip7UmGm8IpIA67e703 JuYA== X-Gm-Message-State: AOAM530LF6GEeQmWHb9diCoyV4D5ZnKqZa0cqxK4+T3y6UF0Yg5Uo3yo EiWiCkVdh3sQ82j9NaLOTEXROYLdDlqZsgzCh1SH+A== X-Google-Smtp-Source: ABdhPJzR7BDh9Ca3MkXwQf+bgt+Bza0FQYsPhBc+iMKM1VlGXSeWit3IupkcyE1arRrDDCtAOdPSXDonDgYOAeXAcKU= X-Received: by 2002:a92:8752:: with SMTP id d18mr7088426ilm.283.1617295820655; Thu, 01 Apr 2021 09:50:20 -0700 (PDT) MIME-Version: 1.0 References: <20210331210841.3996155-1-bgardon@google.com> <20210331210841.3996155-13-bgardon@google.com> In-Reply-To: From: Ben Gardon Date: Thu, 1 Apr 2021 09:50:09 -0700 Message-ID: Subject: Re: [PATCH 12/13] KVM: x86/mmu: Fast invalidation for TDP MMU To: Sean Christopherson Cc: LKML , kvm , Paolo Bonzini , Peter Xu , Peter Shier , Peter Feiner , Junaid Shahid , Jim Mattson , Yulei Zhang , Wanpeng Li , Vitaly Kuznetsov , Xiao Guangrong Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 31, 2021 at 3:27 PM Sean Christopherson wrote: > > 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. Yeah, that's fair. I'll open-code it here. I agree that it will remove confusion from the function, though it would be nice to be able to use for_each_tdp_mmu_root for the lockdep and rcu annotations. > > > + */ > > +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; > > +}