Skip to content

Commit ffe0678

Browse files
author
Matthew Wilcox (Oracle)
committed
mm/migrate: Use a folio in alloc_migration_target()
This removes an assumption that a large folio is HPAGE_PMD_ORDER as well as letting us remove the call to prep_transhuge_page() and a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Zi Yan <[email protected]> Reviewed-by: William Kucharski <[email protected]>
1 parent 83a8441 commit ffe0678

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

mm/migrate.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,45 +1520,43 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
15201520

15211521
struct page *alloc_migration_target(struct page *page, unsigned long private)
15221522
{
1523+
struct folio *folio = page_folio(page);
15231524
struct migration_target_control *mtc;
15241525
gfp_t gfp_mask;
15251526
unsigned int order = 0;
1526-
struct page *new_page = NULL;
1527+
struct folio *new_folio = NULL;
15271528
int nid;
15281529
int zidx;
15291530

15301531
mtc = (struct migration_target_control *)private;
15311532
gfp_mask = mtc->gfp_mask;
15321533
nid = mtc->nid;
15331534
if (nid == NUMA_NO_NODE)
1534-
nid = page_to_nid(page);
1535+
nid = folio_nid(folio);
15351536

1536-
if (PageHuge(page)) {
1537-
struct hstate *h = page_hstate(compound_head(page));
1537+
if (folio_test_hugetlb(folio)) {
1538+
struct hstate *h = page_hstate(&folio->page);
15381539

15391540
gfp_mask = htlb_modify_alloc_mask(h, gfp_mask);
15401541
return alloc_huge_page_nodemask(h, nid, mtc->nmask, gfp_mask);
15411542
}
15421543

1543-
if (PageTransHuge(page)) {
1544+
if (folio_test_large(folio)) {
15441545
/*
15451546
* clear __GFP_RECLAIM to make the migration callback
15461547
* consistent with regular THP allocations.
15471548
*/
15481549
gfp_mask &= ~__GFP_RECLAIM;
15491550
gfp_mask |= GFP_TRANSHUGE;
1550-
order = HPAGE_PMD_ORDER;
1551+
order = folio_order(folio);
15511552
}
1552-
zidx = zone_idx(page_zone(page));
1553+
zidx = zone_idx(folio_zone(folio));
15531554
if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE)
15541555
gfp_mask |= __GFP_HIGHMEM;
15551556

1556-
new_page = __alloc_pages(gfp_mask, order, nid, mtc->nmask);
1557-
1558-
if (new_page && PageTransHuge(new_page))
1559-
prep_transhuge_page(new_page);
1557+
new_folio = __folio_alloc(gfp_mask, order, nid, mtc->nmask);
15601558

1561-
return new_page;
1559+
return &new_folio->page;
15621560
}
15631561

15641562
#ifdef CONFIG_NUMA

0 commit comments

Comments
 (0)