From: Pedro Demarchi Gomes Date: Sat, 4 Oct 2025 03:02:10 +0000 (-0300) Subject: KVM: guest_memfd: use folio_nr_pages() instead of shift operation X-Git-Tag: v6.19-rc1~103^2~10^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=765fcd7c0753cc62d0a839cbd8355cfaf57a7eb6;p=thirdparty%2Flinux.git KVM: guest_memfd: use folio_nr_pages() instead of shift operation 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 Link: https://lore.kernel.org/r/20251004030210.49080-1-pedrodemargomes@gmail.com Signed-off-by: Sean Christopherson --- diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c index caa87efc8f7ae..9017e4d77c538 100644 --- a/virt/kvm/guest_memfd.c +++ b/virt/kvm/guest_memfd.c @@ -82,9 +82,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 = kvm_gmem_get_index(slot, gfn); - 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);