* [PATCH] KVM: use folio_nr_pages() instead of shift operation
@ 2025-10-04 3:02 Pedro Demarchi Gomes
2025-10-15 18:02 ` Sean Christopherson
2025-10-22 19:40 ` David Hildenbrand
0 siblings, 2 replies; 4+ messages in thread
From: Pedro Demarchi Gomes @ 2025-10-04 3:02 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Pedro Demarchi Gomes
folio_nr_pages() is a faster helper function to get the number of pages when
NR_PAGES_IN_LARGE_FOLIO is enabled.
Signed-off-by: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>
---
virt/kvm/guest_memfd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
index 7d85cc33c0bb..5fc5475cf826 100644
--- a/virt/kvm/guest_memfd.c
+++ b/virt/kvm/guest_memfd.c
@@ -77,9 +77,9 @@ static int kvm_gmem_prepare_folio(struct kvm *kvm, struct kvm_memory_slot *slot,
* The order will be passed when creating the guest_memfd, and
* checked when creating memslots.
*/
- WARN_ON(!IS_ALIGNED(slot->gmem.pgoff, 1 << folio_order(folio)));
+ WARN_ON(!IS_ALIGNED(slot->gmem.pgoff, folio_nr_pages(folio)));
index = gfn - slot->base_gfn + slot->gmem.pgoff;
- index = ALIGN_DOWN(index, 1 << folio_order(folio));
+ index = ALIGN_DOWN(index, folio_nr_pages(folio));
r = __kvm_gmem_prepare_folio(kvm, slot, index, folio);
if (!r)
kvm_gmem_mark_prepared(folio);
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: use folio_nr_pages() instead of shift operation
2025-10-04 3:02 [PATCH] KVM: use folio_nr_pages() instead of shift operation Pedro Demarchi Gomes
@ 2025-10-15 18:02 ` Sean Christopherson
2025-10-20 15:51 ` Sean Christopherson
2025-10-22 19:40 ` David Hildenbrand
1 sibling, 1 reply; 4+ messages in thread
From: Sean Christopherson @ 2025-10-15 18:02 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini, Pedro Demarchi Gomes
Cc: kvm, linux-kernel
On Sat, 04 Oct 2025 00:02:10 -0300, Pedro Demarchi Gomes wrote:
> folio_nr_pages() is a faster helper function to get the number of pages when
> NR_PAGES_IN_LARGE_FOLIO is enabled.
Applied to kvm-x86 gmem, thanks!
[1/1] KVM: use folio_nr_pages() instead of shift operation
https://github.com/kvm-x86/linux/commit/fa492ac7fb04
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: use folio_nr_pages() instead of shift operation
2025-10-15 18:02 ` Sean Christopherson
@ 2025-10-20 15:51 ` Sean Christopherson
0 siblings, 0 replies; 4+ messages in thread
From: Sean Christopherson @ 2025-10-20 15:51 UTC (permalink / raw)
To: Paolo Bonzini, Pedro Demarchi Gomes; +Cc: kvm, linux-kernel
On Wed, Oct 15, 2025, Sean Christopherson wrote:
> On Sat, 04 Oct 2025 00:02:10 -0300, Pedro Demarchi Gomes wrote:
> > folio_nr_pages() is a faster helper function to get the number of pages when
> > NR_PAGES_IN_LARGE_FOLIO is enabled.
>
> Applied to kvm-x86 gmem, thanks!
>
> [1/1] KVM: use folio_nr_pages() instead of shift operation
> https://github.com/kvm-x86/linux/commit/fa492ac7fb04
FYI, I rebased this onto 6.18-rc2 to avoid a silly merge. New hash:
[1/1] KVM: guest_memfd: use folio_nr_pages() instead of shift operation
https://github.com/kvm-x86/linux/commit/765fcd7c0753
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: use folio_nr_pages() instead of shift operation
2025-10-04 3:02 [PATCH] KVM: use folio_nr_pages() instead of shift operation Pedro Demarchi Gomes
2025-10-15 18:02 ` Sean Christopherson
@ 2025-10-22 19:40 ` David Hildenbrand
1 sibling, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2025-10-22 19:40 UTC (permalink / raw)
To: Pedro Demarchi Gomes, Paolo Bonzini; +Cc: kvm, linux-kernel
On 04.10.25 05:02, Pedro Demarchi Gomes wrote:
> folio_nr_pages() is a faster helper function to get the number of pages when
> NR_PAGES_IN_LARGE_FOLIO is enabled.
>
> Signed-off-by: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>
> ---
> virt/kvm/guest_memfd.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> index 7d85cc33c0bb..5fc5475cf826 100644
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@ -77,9 +77,9 @@ static int kvm_gmem_prepare_folio(struct kvm *kvm, struct kvm_memory_slot *slot,
> * The order will be passed when creating the guest_memfd, and
> * checked when creating memslots.
> */
> - WARN_ON(!IS_ALIGNED(slot->gmem.pgoff, 1 << folio_order(folio)));
> + WARN_ON(!IS_ALIGNED(slot->gmem.pgoff, folio_nr_pages(folio)));
> index = gfn - slot->base_gfn + slot->gmem.pgoff;
> - index = ALIGN_DOWN(index, 1 << folio_order(folio));
> + index = ALIGN_DOWN(index, folio_nr_pages(folio));
> r = __kvm_gmem_prepare_folio(kvm, slot, index, folio);
> if (!r)
> kvm_gmem_mark_prepared(folio);
FWIW
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-22 19:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-04 3:02 [PATCH] KVM: use folio_nr_pages() instead of shift operation Pedro Demarchi Gomes
2025-10-15 18:02 ` Sean Christopherson
2025-10-20 15:51 ` Sean Christopherson
2025-10-22 19:40 ` David Hildenbrand
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).