Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Keep subpage private zero at free and folio split time
@ 2026-06-29  2:56 Zi Yan
  2026-06-29  2:56 ` [PATCH 1/4] mm/compaction: stop recording free page order in page->private Zi Yan
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Zi Yan @ 2026-06-29  2:56 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka, Suren Baghdasaryan, Michal Hocko,
	Brendan Jackman, Johannes Weiner, David Hildenbrand,
	Lorenzo Stoakes, Baolin Wang, Liam R. Howlett, Nico Pache,
	Ryan Roberts, Dev Jain, Barry Song, Lance Yang, Mike Rapoport
  Cc: linux-mm, linux-kernel, Zi Yan

Hi all,

This patchset makes sure subpage->private is zero before compound or
high-order pages are returned to the allocator. It also checks subpages
that become new folio heads during large folio split, before their private
fields are used by new folios.

It is based on v7.2-rc1.

Motivation ===

page->private is zeroed at page free time since commit ac1ea219590c0
("mm/page_alloc: clear page->private in free_pages_prepare()"), since we
concluded that it might be too much to ask every page user to free a page
with ->private zeroed. The holder of the last page reference might not know
whether ->private needs to be cleared.

For compound and high-order pages, subpage->private can also leak to later
users if it is left uncleared. The page allocation path does not zero every
subpage->private field, so they can be seen by new users and cause
unexpected issues[1].

Check subpage->private at page free time, and check tail pages that become
new folio heads during large folio split. With those checks in place,
prep_compound_tail() no longer needs to clear subpage->private when
preparing compound page metadata.

Overview ===
1. Patch 1 removes setting page->private in compaction code when a free
   page is taken out of the buddy allocator. cc->freepages is indexed by
   page order, so storing the free page order in page->private is
   redundant.
2. Patch 2 adds back the page->private check for tail pages promoted to new
   folio heads in __split_folio_to_order().
3. Patch 3 adds a subpage->private check in the page free path.
4. Patch 4 removes subpage->private zeroing from prep_compound_tail().

Link: https://lore.kernel.org/all/20260206174017.128673-1-mikhail.v.gavrilov@gmail.com/ [1]

Signed-off-by: Zi Yan <ziy@nvidia.com>
---
Zi Yan (4):
      mm/compaction: stop recording free page order in page->private
      mm/huge_memory: add page->private check back in __split_folio_to_order()
      mm/page_alloc: make sure subpage->private is zero at page free time
      mm/page_alloc: remove set_page_private() in prep_compound_tail()

 mm/compaction.c  |  3 ---
 mm/huge_memory.c | 10 ++++++++++
 mm/internal.h    |  1 -
 mm/page_alloc.c  | 12 +++++++++---
 4 files changed, 19 insertions(+), 7 deletions(-)
---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260603-keep-subpage-private-zero-at-free-a1e1435025dc

Best regards,
-- 
Yan, Zi



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-07-01  8:58 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29  2:56 [PATCH 0/4] Keep subpage private zero at free and folio split time Zi Yan
2026-06-29  2:56 ` [PATCH 1/4] mm/compaction: stop recording free page order in page->private Zi Yan
2026-06-29 14:28   ` Vlastimil Babka (SUSE)
2026-06-29 15:03     ` Zi Yan
2026-06-30  1:32   ` Baolin Wang
2026-06-30  1:37     ` Zi Yan
2026-07-01  8:54       ` David Hildenbrand (Arm)
2026-07-01  6:49   ` Lance Yang
2026-06-29  2:56 ` [PATCH 2/4] mm/huge_memory: add page->private check back in __split_folio_to_order() Zi Yan
2026-06-29 14:39   ` Vlastimil Babka (SUSE)
2026-06-29 15:05     ` Zi Yan
2026-07-01  8:56     ` David Hildenbrand (Arm)
2026-06-29  2:56 ` [PATCH 3/4] mm/page_alloc: make sure subpage->private is zero at page free time Zi Yan
2026-06-29 14:53   ` Vlastimil Babka (SUSE)
2026-06-29 15:07     ` Zi Yan
2026-06-29  2:56 ` [PATCH 4/4] mm/page_alloc: remove set_page_private() in prep_compound_tail() Zi Yan
2026-06-29 15:45   ` Vlastimil Babka (SUSE)
2026-06-29 16:50     ` Zi Yan
2026-07-01  8:58   ` David Hildenbrand (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox