Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] mm: Track vmemmap optimization state in shared backing pages
@ 2026-12-06  8:13 Muchun Song
  2026-12-06  8:13 ` [PATCH v2 1/3] mm: move MAX_FOLIO_VMEMMAP_ALIGN to mmzone.h Muchun Song
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Muchun Song @ 2026-12-06  8:13 UTC (permalink / raw)
  To: Oscar Salvador, David Hildenbrand, Mike Rapoport, Andrew Morton
  Cc: Muchun Song, Liam R . Howlett, Vlastimil Babka, Michal Hocko,
	Miaohe Lin, Naoya Horiguchi, Lance Yang, Qi Zheng, linux-mm,
	loongarch, Huacai Chen, Muchun Song

Folio-based vmemmap optimization currently requires HugeTLB to maintain
HPG_vmemmap_optimized separately from the vmemmap mapping.  The runtime
update is counterintuitive: when TLB flushing is deferred, the flag must
be set before remapping so that it is copied to the replacement head
page, then cleared if optimization fails.  Boot-time HugeTLB setup also
needs an explicit transfer from section metadata into the flag.

The same representation is useful to future shared-vmemmap users [1].
The FS-DAX prototype currently determines whether a metadata page still
uses shared backing by looking up its vmemmap PTE and comparing the mapped
backing page with the shared template.  A future revision can instead
test the common flag directly through the vmemmap address, avoiding
page-table identity as the state representation for shared metadata.

Reuse PG_owner_priv_1 in the first struct page slot of each shared
backing page, and provide folio_vmemmap_optimized() as the common query.
Patch 1 moves MAX_FOLIO_VMEMMAP_ALIGN to mmzone.h, which lets
vmemmap-optimization.h include linux/mm.h.  Patch 2 introduces the
generic state representation and query.  Patch 3 switches HugeTLB to
it and removes the private flag and its explicit state updates.

[1] https://lore.kernel.org/20260903122128.12264-4-songmuchun@bytedance.com/
[2] https://lore.kernel.org/20261205121205.83068-1-songmuchun@bytedance.com/

v2:
- Patch 1 is new.  It moves MAX_FOLIO_VMEMMAP_ALIGN to mmzone.h and
  drops the LoongArch include of vmemmap-optimization.h, fixing the
  circular include that broke the LoongArch build (reported by
  sashiko-bot and kernel test robot)
- Patch 2: Move PG_vmemmap_optimized to PG_owner_priv_1, since
  PG_owner_2 aliases PG_anon_exclusive on THP tail pages (reported by
  sashiko-bot)
- Patch 2: Document that folio_vmemmap_optimized() returns true only
  after the TLB flush has completed (suggested by sashiko-bot)
- Patch 3: No change.  The race between folio_vmemmap_optimized() and
  vmemmap_restore_folio() reported by sashiko-bot is fixed by [2].

v1: https://lore.kernel.org/20261204065009.1392156-1-songmuchun@bytedance.com/

Muchun Song (3):
  mm: move MAX_FOLIO_VMEMMAP_ALIGN to mmzone.h
  mm/vmemmap-optimization: track optimization state in shared vmemmap
    pages
  mm/hugetlb_vmemmap: remove HPG_vmemmap_optimized

 arch/loongarch/include/asm/pgtable.h |  1 -
 include/linux/hugetlb.h              |  3 --
 include/linux/mmzone.h               |  2 ++
 include/linux/page-flags.h           |  6 ++++
 include/linux/vmemmap-optimization.h | 21 +++++++------
 mm/hugetlb.c                         | 15 ++++-----
 mm/hugetlb_vmemmap.c                 | 47 ++++++----------------------
 mm/memory-failure.c                  |  4 +--
 mm/sparse-vmemmap.c                  |  1 +
 9 files changed, 38 insertions(+), 62 deletions(-)


base-commit: 6855c02e7d65a8539dc3f8a24946c1ff9bd81361
-- 
2.54.0



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

end of thread, other threads:[~2026-12-06 17:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-06  8:13 [PATCH v2 0/3] mm: Track vmemmap optimization state in shared backing pages Muchun Song
2026-12-06  8:13 ` [PATCH v2 1/3] mm: move MAX_FOLIO_VMEMMAP_ALIGN to mmzone.h Muchun Song
2026-12-06  8:35   ` sashiko-bot
2026-12-06  8:40     ` Muchun Song
2026-12-06  8:13 ` [PATCH v2 2/3] mm/vmemmap-optimization: track optimization state in shared vmemmap pages Muchun Song
2026-12-06  8:35   ` sashiko-bot
2026-12-06  9:17     ` Muchun Song
2026-12-06 17:30       ` Andrew Morton
2026-12-06  8:13 ` [PATCH v2 3/3] mm/hugetlb_vmemmap: remove HPG_vmemmap_optimized Muchun Song

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