All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Advait Dhamorikar <advaitdhamorikar@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	 Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, hpa@zytor.com,  kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
	 anupnewsmail@gmail.com
Subject: Re: [PATCH-next] KVM: x86/tdp_mmu: Fix redundant u16 compared to 0
Date: Mon, 11 Nov 2024 10:55:59 -0800	[thread overview]
Message-ID: <ZzJTPx1ca4JF8FU-@google.com> (raw)
In-Reply-To: <20241111183935.8550-1-advaitdhamorikar@gmail.com>

On Tue, Nov 12, 2024, Advait Dhamorikar wrote:
> An unsigned value can never be negative,
> so this test will always evaluate the same way.
> `_as_id` a u16 is compared to 0.

Please wrap changelogs at ~75 characters.

> Signed-off-by: Advait Dhamorikar <advaitdhamorikar@gmail.com>
> ---
>  arch/x86/kvm/mmu/tdp_mmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
> index 4508d868f1cd..b4e7b6a264d6 100644
> --- a/arch/x86/kvm/mmu/tdp_mmu.c
> +++ b/arch/x86/kvm/mmu/tdp_mmu.c
> @@ -153,7 +153,7 @@ static struct kvm_mmu_page *tdp_mmu_next_root(struct kvm *kvm,
>  	for (_root = tdp_mmu_next_root(_kvm, NULL, _only_valid);		\
>  	     ({ lockdep_assert_held(&(_kvm)->mmu_lock); }), _root;		\
>  	     _root = tdp_mmu_next_root(_kvm, _root, _only_valid))		\
> -		if (_as_id >= 0 && kvm_mmu_page_as_id(_root) != _as_id) {	\
> +		if (kvm_mmu_page_as_id(_root) != _as_id) {	\

NAK, the comparison is necessary as kvm_tdp_mmu_zap_leafs() deliberately invokes
for_each_valid_tdp_mmu_root_yield_safe() => __for_each_tdp_mmu_root_yield_safe()
with -1 to iterate over all address spaces.

And I don't want to drop the check for __for_each_tdp_mmu_root(), even though
there aren't any _current_ users that pass -1, as I want to keep the iterators
symmetrical.

  reply	other threads:[~2024-11-11 18:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 18:39 [PATCH-next] KVM: x86/tdp_mmu: Fix redundant u16 compared to 0 Advait Dhamorikar
2024-11-11 18:55 ` Sean Christopherson [this message]
2024-11-12  4:17   ` Advait Dhamorikar

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=ZzJTPx1ca4JF8FU-@google.com \
    --to=seanjc@google.com \
    --cc=advaitdhamorikar@gmail.com \
    --cc=anupnewsmail@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=skhan@linuxfoundation.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.