diff options
author | Kefeng Wang <wangkefeng.wang@huawei.com> | 2022-12-29 15:25:03 +0300 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2023-01-19 04:12:51 +0300 |
commit | 630e7c5ee3399be509447035428994e2d88f12c1 (patch) | |
tree | 78da22b957a676b81c4cc8994c9439343b5a3878 | |
parent | c2ca7a59a4199059556b57cfdf98fcf46039ca6b (diff) | |
download | linux-630e7c5ee3399be509447035428994e2d88f12c1.tar.xz |
mm: huge_memory: convert split_huge_pages_all() to use a folio
Straightforwardly convert split_huge_pages_all() to use a folio.
Link: https://lkml.kernel.org/r/20221229122503.149083-1-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | mm/huge_memory.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0ea6510a3be7..7e68a36b4f7d 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2935,6 +2935,7 @@ static void split_huge_pages_all(void) { struct zone *zone; struct page *page; + struct folio *folio; unsigned long pfn, max_zone_pfn; unsigned long total = 0, split = 0; @@ -2947,24 +2948,32 @@ static void split_huge_pages_all(void) int nr_pages; page = pfn_to_online_page(pfn); - if (!page || !get_page_unless_zero(page)) + if (!page || PageTail(page)) + continue; + folio = page_folio(page); + if (!folio_try_get(folio)) continue; - if (zone != page_zone(page)) + if (unlikely(page_folio(page) != folio)) + goto next; + + if (zone != folio_zone(folio)) goto next; - if (!PageHead(page) || PageHuge(page) || !PageLRU(page)) + if (!folio_test_large(folio) + || folio_test_hugetlb(folio) + || !folio_test_lru(folio)) goto next; total++; - lock_page(page); - nr_pages = thp_nr_pages(page); - if (!split_huge_page(page)) + folio_lock(folio); + nr_pages = folio_nr_pages(folio); + if (!split_folio(folio)) split++; pfn += nr_pages - 1; - unlock_page(page); + folio_unlock(folio); next: - put_page(page); + folio_put(folio); cond_resched(); } } |