[PATCH 3/4] mm: Fix demotion gfp by clearing GFP_RECLAIM after setting GFP_TRANSHUGE

From: Alexandre Ghiti

Date: Wed Mar 11 2026 - 07:04:24 EST


GFP_TRANSHUGE sets __GFP_DIRECT_RECLAIM so we must clear GFP_RECLAIM
after, not before.

Reported-by: Bing Jiao <bingjiao@xxxxxxxxxx>
Closes: https://lore.kernel.org/linux-mm/aXlKOxGGI9zne8sl@xxxxxxxxxx/
Fixes: 9933a0c8a539 ("mm/migrate: clear __GFP_RECLAIM to make the migration callback consistent with regular THP allocations")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Alexandre Ghiti <alex@xxxxxxxx>
---
mm/migrate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 2c3d489ecf51..ee533a4d38db 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2190,12 +2190,12 @@ struct folio *alloc_migration_target(struct folio *src, unsigned long private)
}

if (folio_test_large(src)) {
+ gfp_mask |= GFP_TRANSHUGE;
/*
* clear __GFP_RECLAIM to make the migration callback
* consistent with regular THP allocations.
*/
gfp_mask &= ~__GFP_RECLAIM;
- gfp_mask |= GFP_TRANSHUGE;
order = folio_order(src);
}
zidx = folio_zonenum(src);
--
2.53.0