Skip to contentSkip to conversation

mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation.

PATCH Applied Zi Yan 3 participants 3 messages Apr 4, 2022

Subsystems (3)
lore
Share & tools
lore

Zi Yan

author
#0 lore raw

PATCH 1/1 mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation.

From: Zi Yan <[email protected]>

With folios support, it is possible to have other than HPAGE_PMD_ORDER THPs, in the form of folios, in the system. Use thp_order() to correctly determine the source page order during migration.

Fixes d68eccad3706 ("mm/filemap: Allow large folios to be added to the page cache")
---
 mm/mempolicy.c | 2 +-
 mm/migrate.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
mm/mempolicy.c +1 -1
index 6b34c5d5e65a..88a74bc4cba5 100644
@@ -1209,7 +1209,7 @@ static struct page *new_page(struct page *page, unsigned long start)
 		struct page *thp;
 
 		thp = alloc_hugepage_vma(GFP_TRANSHUGE, vma, address,
-					 HPAGE_PMD_ORDER);
+					 thp_order(page));
 		if (!thp)
 			return NULL;
 		prep_transhuge_page(thp);
mm/migrate.c +1 -1
index 4639dfc2b7ee..b58b96fdb174 100644
@@ -1553,7 +1553,7 @@ struct page *alloc_migration_target(struct page *page, unsigned long private)
 		 */
 		gfp_mask &= ~__GFP_RECLAIM;
 		gfp_mask |= GFP_TRANSHUGE;
-		order = HPAGE_PMD_ORDER;
+		order = thp_order(page);
 	}
 	zidx = zone_idx(page_zone(page));
 	if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE)
Signature · 1 line
2.35.1
maintainer
#1 lore raw
Quoted 5 lines · On Mon, 4 Apr 2022 12:53:25 -0400 Zi Yan <[email protected]> wrote:

From: Zi Yan <[email protected]>

With folios support, it is possible to have other than HPAGE_PMD_ORDER THPs, in the form of folios, in the system. Use thp_order() to correctly determine the source page order during migration.

Changelog doesn't describe the end user visible effects of the bug. And it really should, because

Quoted 1 line

it fixes a kernel crash!

reviewer
#2 lore raw
Quoted 8 lines · Andrew Morton
Quoted 5 lines · On Mon, 4 Apr 2022 12:53:25 -0400 Zi Yan <[email protected]> wrote:

From: Zi Yan <[email protected]>

With folios support, it is possible to have other than HPAGE_PMD_ORDER THPs, in the form of folios, in the system. Use thp_order() to correctly determine the source page order during migration.

Quoted 6 lines

Changelog doesn't describe the end user visible effects of the bug. And it really should, because

Quoted 1 line

it fixes a kernel crash!

Thank you for adding the information.

--
Best Regards,
Yan, Zi