[RFC PATCH 10/26] mm: page_alloc: allow compaction capturing from larger blocks
From: Johannes Weiner
Date: Tue Apr 18 2023 - 15:15:07 EST
Currently, capturing only works on matching orders and matching
migratetypes. However, if capturing is initially skipped on the
migratetype, it's possible that merging continues up to a full
pageblock, in which case the migratetype is up for grabs again.
Allow capturing to grab smaller chunks from claimed pageblocks, and
expand the remainder of the block back onto the freelists.
Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
---
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 cd86f80d7bbe..5ebfcf18537b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1067,10 +1067,10 @@ static inline struct capture_control *task_capc(struct zone *zone)
}
static inline bool
-compaction_capture(struct capture_control *capc, struct page *page,
- int order, int migratetype)
+compaction_capture(struct zone *zone, struct page *page, int order,
+ int migratetype, struct capture_control *capc)
{
- if (!capc || order != capc->cc->order)
+ if (!capc || order < capc->cc->order)
return false;
/* Do not accidentally pollute CMA or isolated regions*/
@@ -1092,6 +1092,9 @@ compaction_capture(struct capture_control *capc, struct page *page,
return false;
}
+ if (order > capc->cc->order)
+ expand(zone, page, capc->cc->order, order, migratetype);
+
capc->page = page;
return true;
}
@@ -1103,8 +1106,8 @@ static inline struct capture_control *task_capc(struct zone *zone)
}
static inline bool
-compaction_capture(struct capture_control *capc, struct page *page,
- int order, int migratetype)
+compaction_capture(struct zone *zone, struct page *page, int order,
+ int migratetype, struct capture_control *capc)
{
return false;
}
@@ -1180,7 +1183,7 @@ static inline void __free_one_page(struct page *page,
while (order < MAX_ORDER - 1) {
int buddy_mt;
- if (compaction_capture(capc, page, order, migratetype))
+ if (compaction_capture(zone, page, order, migratetype, capc))
return;
buddy = find_buddy_page_pfn(page, pfn, order, &buddy_pfn);
--
2.39.2