Skip to content

Commit

Permalink
mm/huge_memory: minor cleanup for split_huge_pages_all
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Miaohe Lin <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: Yang Shi <[email protected]>
Cc: Zach O'Keefe <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
MiaoheLin authored and akpm00 committed Jul 18, 2022
1 parent 0b17546 commit a17206d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2857,9 +2857,12 @@ static void split_huge_pages_all(void)
unsigned long total = 0, split = 0;

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);
for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
int nr_pages;
if (!pfn_valid(pfn))
continue;

Expand All @@ -2875,8 +2878,10 @@ static void split_huge_pages_all(void)

total++;
lock_page(page);
nr_pages = thp_nr_pages(page);
if (!split_huge_page(page))
split++;
pfn += nr_pages - 1;
unlock_page(page);
next:
put_page(page);
Expand Down

0 comments on commit a17206d

Please sign in to comment.