Skip to contentSkip to conversation

mm: prep_compound_tail() clear page->private

PATCH Applied Hugh Dickins 2 participants 2 messages Oct 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: prep_compound_tail() clear page->private

Although page allocation always clears page->private in the first page or head page of an allocation, it has never made a point of clearing page->private in the tails (though 0 is often what is already there).

But now commit 71e2d666ef85 ("mm/huge_memory: do not clobber swp_entry_t during THP split") issues a warning when page_tail->private is found to be non-0 (unless it's swapcache).

Change that warning to dump page_tail (which also dumps head), instead of just the head: so far we have seen dead000000000122, dead000000000003, dead000000000001 or 0000000000000002 in the raw output for tail private.

We could just delete the warning, but today's consensus appears to want page->private to be 0, unless there's a good reason for it to be set:
so now clear it in prep_compound_tail() (more general than just for THP; but not for high order allocation, which makes no pass down the tails).

Fixes 71e2d666ef85 ("mm/huge_memory: do not clobber swp_entry_t during THP split")
Cc Mel Gorman <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
---
 mm/huge_memory.c | 2 +-
 mm/page_alloc.c  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
mm/huge_memory.c +1 -1
index 03fc7e5edf07..561a42567477 100644
@@ -2462,7 +2462,7 @@ static void __split_huge_page_tail(struct page *head, int tail,
 	 * Fix up and warn once if private is unexpectedly set.
 	 */
 	if (!folio_test_swapcache(page_folio(head))) {
-		VM_WARN_ON_ONCE_PAGE(page_tail->private != 0, head);
+		VM_WARN_ON_ONCE_PAGE(page_tail->private != 0, page_tail);
 		page_tail->private = 0;
 	}
 
mm/page_alloc.c +1 -0
index b5a6c815ae28..218b28ee49ed 100644
@@ -807,6 +807,7 @@ static void prep_compound_tail(struct page *head, int tail_idx)
 
 	p->mapping = TAIL_MAPPING;
 	set_compound_head(p, head);
+	set_page_private(p, 0);
 }
 
 void prep_compound_page(struct page *page, unsigned int order)
Signature · 1 line
2.35.3
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Hugh Dickins

Although page allocation always clears page->private in the first page or head page of an allocation, it has never made a point of clearing page->private in the tails (though 0 is often what is already there).

Quoted 8 lines

But now commit 71e2d666ef85 ("mm/huge_memory: do not clobber swp_entry_t during THP split") issues a warning when page_tail->private is found to be non-0 (unless it's swapcache).

Change that warning to dump page_tail (which also dumps head), instead of just the head: so far we have seen dead000000000122, dead000000000003, dead000000000001 or 0000000000000002 in the raw output for tail private.

The intent behind dumping the head was because I expected we'd be mid-split and the head page was more meaningful but your patch also works.

Quoted 2 lines

We could just delete the warning, but today's consensus appears to want page->private to be 0, unless there's a good reason for it to be set:

This was also on purpose. I suspected the warning would create a few new reports but if page->private should be 0 then it's better to start catching it now instead of later. At least we're still in an early rc kernel.

Quoted 8 lines

so now clear it in prep_compound_tail() (more general than just for THP; but not for high order allocation, which makes no pass down the tails).

Fixes 71e2d666ef85 ("mm/huge_memory: do not clobber swp_entry_t during THP split")
Cc Mel Gorman <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>

Thanks Hugh.

Signature · 2 lines
Mel Gorman
SUSE Labs