All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	hpa@zytor.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86/mmu: use helper macro SPTE_ENT_PER_PAGE
Date: Wed, 5 Oct 2022 23:17:31 +0000	[thread overview]
Message-ID: <Yz4Qi7cn7TWTWQjj@google.com> (raw)
In-Reply-To: <20220913085452.25561-1-linmiaohe@huawei.com>

On Tue, Sep 13, 2022, Miaohe Lin wrote:
> Use helper macro SPTE_ENT_PER_PAGE to get the number of spte entries
> per page. Minor readability improvement.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---

Reviewed-by: Sean Christopherson <seanjc@google.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 858bc53cfab4..45c532d00f78 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -1645,7 +1645,7 @@ static int is_empty_shadow_page(u64 *spt)
>  	u64 *pos;
>  	u64 *end;
>  
> -	for (pos = spt, end = pos + PAGE_SIZE / sizeof(u64); pos != end; pos++)
> +	for (pos = spt, end = pos + SPTE_ENT_PER_PAGE; pos != end; pos++)

This is buried under MMU_DEBUG, and turning that on to compile test, which requires
manually changing kernel code to enable, results in some minor warnings.  Given the
existence of CONFIG_KVM_WERROR=y, I think it's safe to say this code hasn't been
exercised in a very long time.  E.g. this is literally the first time I've actually
enabled MMU_DEBUG.

This particular check seems like it would be quite useful, but the pgprintk() and
rmap_printk() hooks, not so much.  E.g. the knob is too coarse grained, and many
of the prints now have tracepoints.

So, unless someone actually actively uses MMU_DEBUG+dbg, I'm inclined to just delete
pgprintk() and rmap_printk(), and then rename MMU_WARN_ON => KVM_MMU_WARN_ON and
add a Kconfig for that, e.g. CONFIG_KVM_PROVE_MMU.

Hmm, and maybe clean up this helper too, e.g. get rid of the pointer arithmetic,
and take the full kvm_mmu_page so that the error message can print out things like
the gfn (a host kernel pointer is going to be useless for debug).

Thoughts?  Objections?

  reply	other threads:[~2022-10-05 23:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13  8:54 [PATCH] KVM: x86/mmu: use helper macro SPTE_ENT_PER_PAGE Miaohe Lin
2022-10-05 23:17 ` Sean Christopherson [this message]
2022-10-15  2:39   ` Miaohe Lin
2022-10-22  8:43 ` Paolo Bonzini

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=Yz4Qi7cn7TWTWQjj@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --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.