@@ -257,9 +257,7 @@ static inline spinlock_t *pud_trans_huge_lock(pud_t *pud,
static inline unsigned int thp_order(struct page *page)
{
VM_BUG_ON_PGFLAGS(PageTail(page), page);
- if (PageHead(page))
- return HPAGE_PMD_ORDER;
- return 0;
+ return compound_order(page);
}
/**
@@ -269,9 +267,7 @@ static inline unsigned int thp_order(struct page *page)
static inline int thp_nr_pages(struct page *page)
{
VM_BUG_ON_PGFLAGS(PageTail(page), page);
- if (PageHead(page))
- return HPAGE_PMD_NR;
- return 1;
+ return compound_nr(page);
}
struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
@@ -715,6 +715,27 @@ int vma_is_stack_for_current(struct vm_area_struct *vma);
struct mmu_gather;
struct inode;
+static inline unsigned int compound_order(struct page *page)
+{
+ if (!PageHead(page))
+ return 0;
+ return page[1].compound_order;
+}
+
+/* Returns the number of pages in this potentially compound page. */
+static inline unsigned long compound_nr(struct page *page)
+{
+ if (!PageHead(page))
+ return 1;
+ return page[1].compound_nr;
+}
+
+static inline void set_compound_order(struct page *page, unsigned int order)
+{
+ page[1].compound_order = order;
+ page[1].compound_nr = 1U << order;
+}
+
#include <linux/huge_mm.h>
/*
@@ -937,13 +958,6 @@ static inline void destroy_compound_page(struct page *page)
compound_page_dtors[page[1].compound_dtor](page);
}
-static inline unsigned int compound_order(struct page *page)
-{
- if (!PageHead(page))
- return 0;
- return page[1].compound_order;
-}
-
/**
* folio_order - The allocation order of a folio.
* @folio: The folio.
@@ -981,20 +995,6 @@ static inline int compound_pincount(struct page *page)
return head_compound_pincount(page);
}
-static inline void set_compound_order(struct page *page, unsigned int order)
-{
- page[1].compound_order = order;
- page[1].compound_nr = 1U << order;
-}
-
-/* Returns the number of pages in this potentially compound page. */
-static inline unsigned long compound_nr(struct page *page)
-{
- if (!PageHead(page))
- return 1;
- return page[1].compound_nr;
-}
-
/* Returns the number of bytes in this potentially compound page. */
static inline unsigned long page_size(struct page *page)
{
Use the compound size of the page instead of assuming PTE or PMD size. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- include/linux/huge_mm.h | 8 ++------ include/linux/mm.h | 42 ++++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 27 deletions(-)