[RFC PATCH 36/45] mm: page_alloc: add alloc_flags parameter to __rmqueue_smallest

Rik van Riel
2026-04-30T20:22:54Z

Plumb alloc_flags through __rmqueue_smallest so that subsequent
diagnostic tracepoints (and any future logic that needs to react to
allocation flags) can observe and use it. No behavioural change: the
parameter is added to the signature and threaded through every caller,
but nothing inside __rmqueue_smallest acts on it yet.

Callers passing 0 for alloc_flags are paths that synthesise an
allocation outside of the normal alloc_flags-tracking flow
(__rmqueue_cma_fallback, the fallback in try_to_claim_block).

Signed-off-by: Rik van Riel <riel@surriel.com>
Assisted-by: Claude:claude-opus-4.7 syzkaller
---
mm/page_alloc.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e8d6d5b47f63..d621e84bf664 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2816,7 +2816,8 @@ struct spb_tainted_walk {

static __always_inline
struct page *__rmqueue_smallest(struct zone *zone, unsigned int order,
- int migratetype, struct spb_tainted_walk *walk)
+ int migratetype, unsigned int alloc_flags,
+ struct spb_tainted_walk *walk)
{
unsigned int current_order;
struct free_area *area;
@@ -3240,7 +3241,7 @@ static inline bool noncompatible_cross_type(int start_type, int fallback_type)
static __always_inline struct page *__rmqueue_cma_fallback(struct zone *zone,
unsigned int order)
{
- return __rmqueue_smallest(zone, order, MIGRATE_CMA, NULL);
+ return __rmqueue_smallest(zone, order, MIGRATE_CMA, 0, NULL);
}
#else
static inline struct page *__rmqueue_cma_fallback(struct zone *zone,
@@ -3715,7 +3716,7 @@ try_to_claim_block(struct zone *zone, struct page *page,
if (sb)
spb_update_list(sb);
#endif
- return __rmqueue_smallest(zone, order, start_type, NULL);
+ return __rmqueue_smallest(zone, order, start_type, 0, NULL);
}

/*
@@ -4116,7 +4117,8 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype,
*/
switch (*mode) {
case RMQUEUE_NORMAL:
- page = __rmqueue_smallest(zone, order, migratetype, walkp);
+ page = __rmqueue_smallest(zone, order, migratetype,
+ alloc_flags, walkp);
if (page)
return page;
/*
@@ -5171,7 +5173,8 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone,
}
if (alloc_flags & ALLOC_HIGHATOMIC)
page = __rmqueue_smallest(zone, order,
- MIGRATE_HIGHATOMIC, NULL);
+ MIGRATE_HIGHATOMIC,
+ alloc_flags, NULL);
if (!page) {
enum rmqueue_mode rmqm = RMQUEUE_NORMAL;

@@ -5186,7 +5189,7 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone,
if (!page && (alloc_flags & (ALLOC_OOM|ALLOC_NON_BLOCK)))
page = __rmqueue_smallest(zone, order,
MIGRATE_HIGHATOMIC,
- NULL);
+ alloc_flags, NULL);

if (!page) {
spin_unlock_irqrestore(&zone->lock, flags);
--
2.52.0