Re: [PATCH] mm/page_alloc: drop flag-conversion "optimisation"

From: Brendan Jackman

Date: Fri Jun 12 2026 - 10:53:46 EST


On Fri Jun 12, 2026 at 2:15 PM UTC, Brendan Jackman wrote:
> - /*
> - * __GFP_HIGH is assumed to be the same as ALLOC_MIN_RESERVE
> - * and __GFP_KSWAPD_RECLAIM is assumed to be the same as ALLOC_KSWAPD
> - * to save two branches.
> - */
> - BUILD_BUG_ON(__GFP_HIGH != (__force gfp_t) ALLOC_MIN_RESERVE);
> - BUILD_BUG_ON(__GFP_KSWAPD_RECLAIM != (__force gfp_t) ALLOC_KSWAPD);

Agh, alloc_flags_nofragment() needs to be updated too:

diff --git c/mm/page_alloc.c i/mm/page_alloc.c
index 9e1949ea13a6d..0111cdbdb5321 100644
--- c/mm/page_alloc.c
+++ i/mm/page_alloc.c
@@ -3739,13 +3739,10 @@ static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone)
static inline unsigned int
alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask)
{
- unsigned int alloc_flags;
+ unsigned int alloc_flags = 0;

- /*
- * __GFP_KSWAPD_RECLAIM is assumed to be the same as ALLOC_KSWAPD
- * to save a branch.
- */
- alloc_flags = (__force int) (gfp_mask & __GFP_KSWAPD_RECLAIM);
+ if (gfp_mask & __GFP_KSWAPD_RECLAIM)
+ alloc_flags |= ALLOC_KSWAPD;

if (defrag_mode) {
alloc_flags |= ALLOC_NOFRAGMENT;

I guess I will just send a v2 once I've tested since this is pretty easy
to review anyway, any objections?