]> www.infradead.org Git - linux-platform-drivers-x86.git/commitdiff
mm/huge_memory: fix can_split_huge_page assumption of THP size
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 16 Oct 2020 03:05:43 +0000 (20:05 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 16 Oct 2020 18:11:15 +0000 (11:11 -0700)
Ask the page how many subpages it has instead of assuming it's PMD size.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SeongJae Park <sjpark@amazon.de>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: "Huang, Ying" <ying.huang@intel.com>
Link: https://lkml.kernel.org/r/20200908195539.25896-8-willy@infradead.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/huge_memory.c

index 6fb75df0e8c060aa2c97167fb7c63de95e7cbb7c..4474cc3b1a4806ef75360f6a503667d871f05472 100644 (file)
@@ -2582,9 +2582,9 @@ bool can_split_huge_page(struct page *page, int *pextra_pins)
 
        /* Additional pins from page cache */
        if (PageAnon(page))
-               extra_pins = PageSwapCache(page) ? HPAGE_PMD_NR : 0;
+               extra_pins = PageSwapCache(page) ? thp_nr_pages(page) : 0;
        else
-               extra_pins = HPAGE_PMD_NR;
+               extra_pins = thp_nr_pages(page);
        if (pextra_pins)
                *pextra_pins = extra_pins;
        return total_mapcount(page) == page_count(page) - extra_pins - 1;