]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm: add thp_order
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Sat, 15 Aug 2020 00:30:30 +0000 (17:30 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 15 Aug 2020 02:56:56 +0000 (19:56 -0700)
This function returns the order of a transparent huge page.  It compiles
to 0 if CONFIG_TRANSPARENT_HUGEPAGE is disabled.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Link: http://lkml.kernel.org/r/20200629151959.15779-4-willy@infradead.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/huge_mm.h

index 467302056e1717ca11a18d2ea7fcecb1641e269f..9521cfdf18ca1340208bd5dcc41166d9fd3a3451 100644 (file)
@@ -258,6 +258,19 @@ static inline spinlock_t *pud_trans_huge_lock(pud_t *pud,
        else
                return NULL;
 }
+
+/**
+ * thp_order - Order of a transparent huge page.
+ * @page: Head page of a transparent huge page.
+ */
+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;
+}
+
 static inline int hpage_nr_pages(struct page *page)
 {
        if (unlikely(PageTransHuge(page)))
@@ -317,6 +330,12 @@ static inline struct list_head *page_deferred_list(struct page *page)
 #define HPAGE_PUD_MASK ({ BUILD_BUG(); 0; })
 #define HPAGE_PUD_SIZE ({ BUILD_BUG(); 0; })
 
+static inline unsigned int thp_order(struct page *page)
+{
+       VM_BUG_ON_PGFLAGS(PageTail(page), page);
+       return 0;
+}
+
 static inline int hpage_nr_pages(struct page *page)
 {
        VM_BUG_ON_PAGE(PageTail(page), page);