Commit a17206da authored by Miaohe Lin's avatar Miaohe Lin Committed by akpm

mm/huge_memory: minor cleanup for split_huge_pages_all

There is nothing to do if a zone doesn't have any pages managed by the
buddy allocator. So we should check managed_zone instead. Also if a thp
is found, there's no need to traverse the subpages again.

Link: https://lkml.kernel.org/r/20220704132201.14611-13-linmiaohe@huawei.comSigned-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Zach O'Keefe <zokeefe@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 0b175468
...@@ -2857,9 +2857,12 @@ static void split_huge_pages_all(void) ...@@ -2857,9 +2857,12 @@ static void split_huge_pages_all(void)
unsigned long total = 0, split = 0; unsigned long total = 0, split = 0;
pr_debug("Split all THPs\n"); pr_debug("Split all THPs\n");
for_each_populated_zone(zone) { for_each_zone(zone) {
if (!managed_zone(zone))
continue;
max_zone_pfn = zone_end_pfn(zone); max_zone_pfn = zone_end_pfn(zone);
for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) { for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
int nr_pages;
if (!pfn_valid(pfn)) if (!pfn_valid(pfn))
continue; continue;
...@@ -2875,8 +2878,10 @@ static void split_huge_pages_all(void) ...@@ -2875,8 +2878,10 @@ static void split_huge_pages_all(void)
total++; total++;
lock_page(page); lock_page(page);
nr_pages = thp_nr_pages(page);
if (!split_huge_page(page)) if (!split_huge_page(page))
split++; split++;
pfn += nr_pages - 1;
unlock_page(page); unlock_page(page);
next: next:
put_page(page); put_page(page);
......
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