[PATCH v8 30/37] mm: page_alloc: propagate PG_zeroed in split_large_buddy

From: Michael S. Tsirkin

Date: Wed May 20 2026 - 18:33:45 EST


When splitting a large buddy page, propagate the PG_zeroed flag
to each sub-page before freeing it. __free_pages_prepare clears
all flags (including PG_zeroed), so the flag must be re-set on
each fragment after the split. This ensures that the buddy merge
logic can see PG_zeroed on pages that were part of a larger
zeroed block.

Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
Reviewed-by: Gregory Price <gourry@xxxxxxxxxx>
Assisted-by: Claude:claude-opus-4-6
Assisted-by: cursor-agent:GPT-5.4-xhigh
---
mm/page_alloc.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 72e52f049cf0..702fa2ced1e1 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1524,6 +1524,7 @@ static void split_large_buddy(struct zone *zone, struct page *page,
{
unsigned long end = pfn + (1 << order);
bool reported = PageReported(page);
+ bool zeroed = PageZeroed(page);

VM_WARN_ON_ONCE(!IS_ALIGNED(pfn, 1 << order));
/* Caller removed page from freelist, buddy info cleared! */
@@ -1537,6 +1538,8 @@ static void split_large_buddy(struct zone *zone, struct page *page,

if (reported)
__SetPageReported(page);
+ if (zeroed)
+ __SetPageZeroed(page);
__free_one_page(page, pfn, zone, order, mt, fpi);
pfn += 1 << order;
if (pfn == end)
--
MST