Commit 630e7c5e authored by Kefeng Wang's avatar Kefeng Wang Committed by Andrew Morton

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.comSigned-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent c2ca7a59
...@@ -2935,6 +2935,7 @@ static void split_huge_pages_all(void) ...@@ -2935,6 +2935,7 @@ static void split_huge_pages_all(void)
{ {
struct zone *zone; struct zone *zone;
struct page *page; struct page *page;
struct folio *folio;
unsigned long pfn, max_zone_pfn; unsigned long pfn, max_zone_pfn;
unsigned long total = 0, split = 0; unsigned long total = 0, split = 0;
...@@ -2947,24 +2948,32 @@ static void split_huge_pages_all(void) ...@@ -2947,24 +2948,32 @@ static void split_huge_pages_all(void)
int nr_pages; int nr_pages;
page = pfn_to_online_page(pfn); 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; continue;
if (zone != page_zone(page)) if (unlikely(page_folio(page) != folio))
goto next;
if (zone != folio_zone(folio))
goto next; goto next;
if (!PageHead(page) || PageHuge(page) || !PageLRU(page)) if (!folio_test_large(folio)
|| folio_test_hugetlb(folio)
|| !folio_test_lru(folio))
goto next; goto next;
total++; total++;
lock_page(page); folio_lock(folio);
nr_pages = thp_nr_pages(page); nr_pages = folio_nr_pages(folio);
if (!split_huge_page(page)) if (!split_folio(folio))
split++; split++;
pfn += nr_pages - 1; pfn += nr_pages - 1;
unlock_page(page); folio_unlock(folio);
next: next:
put_page(page); folio_put(folio);
cond_resched(); cond_resched();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment