public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Hao Peng <flyingpenghao@gmail.com>
Cc: pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kvm: mmu: Simplify judgment conditions
Date: Tue, 26 Jul 2022 14:41:20 +0000	[thread overview]
Message-ID: <Yt/9EJienmR2i+va@google.com> (raw)
In-Reply-To: <CAPm50aLYb9+wsm3WA8buhC+ePfR6TrGbDR0nMju+bLzf0Tozuw@mail.gmail.com>

On Tue, Jul 26, 2022, Hao Peng wrote:
> From: Peng Hao <flyingpeng@tencent.com>
> 
> kvm_shadow_root_allocated() has been checked before in
> mmu_first_shadow_root_alloc,
> and subsequent kvm_memslots_have_rmaps() does not need to check
> kvm_shadow_root_allocated() again.

Heh, this has come up before[*].  I agree with Paolo that checking for rmaps is
more intuitive than checking for !TDP MMU.  I'm not sure I agree about dropping
the check entirely though, it just seems like we'll end up back here again, i.e.
someone will inevitably propose optimizing the case where KVM has already allocated
rmaps and gfn_track.

[*] https://lore.kernel.org/all/c31a5f84-6da2-c6a0-c0cd-9f6802c39fc3@redhat.com

> Signed-off-by: Peng Hao <flyingpeng@tencent.com>
> ---
>  arch/x86/kvm/mmu/mmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 52664c3caaab..ecd64c06f839 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -3584,7 +3584,7 @@ static int mmu_first_shadow_root_alloc(struct kvm *kvm)
>          * Check if anything actually needs to be allocated, e.g. all metadata
>          * will be allocated upfront if TDP is disabled.
>          */
> -       if (kvm_memslots_have_rmaps(kvm) &&
> +       if (!is_tdp_mmu_enabled(kvm) &&
>             kvm_page_track_write_tracking_enabled(kvm))
>                 goto out_success;
> 
> --
> 2.27.0

      reply	other threads:[~2022-07-26 14:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-26  1:59 [PATCH] kvm: mmu: Simplify judgment conditions Hao Peng
2022-07-26 14:41 ` Sean Christopherson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yt/9EJienmR2i+va@google.com \
    --to=seanjc@google.com \
    --cc=flyingpenghao@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox