]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm: define __pte_leaf_size() to also take a PMD entry
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 2 Jul 2024 13:51:19 +0000 (15:51 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 12 Jul 2024 22:52:15 +0000 (15:52 -0700)
On powerpc 8xx, when a page is 8M size, the information is in the PMD
entry.  So allow architectures to provide __pte_leaf_size() instead of
pte_leaf_size() and provide the PMD entry to that function.

When __pte_leaf_size() is not defined, define it as a pte_leaf_size() so
that architectures not interested in the PMD arguments are not impacted.

Only define a default pte_leaf_size() when __pte_leaf_size() is not
defined to make sure nobody adds new calls to pte_leaf_size() in the core.

Link: https://lkml.kernel.org/r/c7c008f0a314bf8029ad7288fdc908db1ec7e449.1719928057.git.christophe.leroy@csgroup.eu
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/pgtable.h
kernel/events/core.c

index 2f32eaccf0b9378fad481096ec918abb3aa14d31..2a6a3cccfc3670ef0aa239dfffb2649c16fd654a 100644 (file)
@@ -1907,9 +1907,12 @@ typedef unsigned int pgtbl_mod_mask;
 #ifndef pmd_leaf_size
 #define pmd_leaf_size(x) PMD_SIZE
 #endif
+#ifndef __pte_leaf_size
 #ifndef pte_leaf_size
 #define pte_leaf_size(x) PAGE_SIZE
 #endif
+#define __pte_leaf_size(x,y) pte_leaf_size(y)
+#endif
 
 /*
  * We always define pmd_pfn for all archs as it's used in lots of generic
index 8f908f0779354d1013dfb8b2406f8ec7e2f42568..b2ca11bdc11ee78cf248b113e1c03f2ef8ee1407 100644 (file)
@@ -7609,7 +7609,7 @@ again:
 
        pte = ptep_get_lockless(ptep);
        if (pte_present(pte))
-               size = pte_leaf_size(pte);
+               size = __pte_leaf_size(pmd, pte);
        pte_unmap(ptep);
 #endif /* CONFIG_HAVE_GUP_FAST */