From: Maxim Levitsky <mlevitsk@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86/mmu: Grab nx_lpage_splits as an unsigned long before division
Date: Wed, 16 Jun 2021 22:01:57 +0300 [thread overview]
Message-ID: <83be37371a61efa72c4364f1dc9a26d19750d8cc.camel@redhat.com> (raw)
In-Reply-To: <20210615162905.2132937-1-seanjc@google.com>
On Tue, 2021-06-15 at 09:29 -0700, Sean Christopherson wrote:
> Snapshot kvm->stats.nx_lpage_splits into a local unsigned long to avoid
> 64-bit division on 32-bit kernels. Casting to an unsigned long is safe
> because the maximum number of shadow pages, n_max_mmu_pages, is also an
> unsigned long, i.e. KVM will start recycling shadow pages before the
> number of splits can exceed a 32-bit value.
>
> ERROR: modpost: "__udivdi3" [arch/x86/kvm/kvm.ko] undefined!
>
> Fixes: 7ee093d4f3f5 ("KVM: switch per-VM stats to u64")
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> arch/x86/kvm/mmu/mmu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 720ceb0a1f5c..7d3e57678d34 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -6043,6 +6043,7 @@ static int set_nx_huge_pages_recovery_ratio(const char *val, const struct kernel
>
> static void kvm_recover_nx_lpages(struct kvm *kvm)
> {
> + unsigned long nx_lpage_splits = kvm->stat.nx_lpage_splits;
> int rcu_idx;
> struct kvm_mmu_page *sp;
> unsigned int ratio;
> @@ -6054,7 +6055,7 @@ static void kvm_recover_nx_lpages(struct kvm *kvm)
> write_lock(&kvm->mmu_lock);
>
> ratio = READ_ONCE(nx_huge_pages_recovery_ratio);
> - to_zap = ratio ? DIV_ROUND_UP(kvm->stat.nx_lpage_splits, ratio) : 0;
> + to_zap = ratio ? DIV_ROUND_UP(nx_lpage_splits, ratio) : 0;
> for ( ; to_zap; --to_zap) {
> if (list_empty(&kvm->arch.lpage_disallowed_mmu_pages))
> break;
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Best regards,
Maxim Levitsky
next prev parent reply other threads:[~2021-06-16 19:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-15 16:29 [PATCH] KVM: x86/mmu: Grab nx_lpage_splits as an unsigned long before division Sean Christopherson
2021-06-16 19:01 ` Maxim Levitsky [this message]
2021-06-17 17:10 ` 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=83be37371a61efa72c4364f1dc9a26d19750d8cc.camel@redhat.com \
--to=mlevitsk@redhat.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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;
as well as URLs for NNTP newsgroup(s).