Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/5] mm/memory_hotplug: optimize zone contiguous check when changing pfn range
@ 2026-05-20  9:34 Yuan Liu
  2026-05-20  9:34 ` [PATCH v5 1/5] mm: move mirrored memory overlap checking to the outer loop Yuan Liu
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Yuan Liu @ 2026-05-20  9:34 UTC (permalink / raw)
  To: David Hildenbrand, Oscar Salvador, Mike Rapoport, Wei Yang
  Cc: linux-mm, Yong Hu, Nanhai Zou, Yuan Liu, Tim Chen, Qiuxu Zhuo,
	Yu C Chen, Pan Deng, Tianyou Li, Chen Zhang, Jason Zeng,
	linux-kernel

This series introduces a pages_with_online_memmap member into struct zone
to avoid pageblock-by-pageblock scans across the entire zone and improve
memory hotplug performance.

For VM hotplug performance data, please refer to Patch 4.
This series also benefits CXL hotplug. Performance results are as follows
https://lore.kernel.org/all/20260409023552.GA2807@AE/

Patches 1 and 2 avoid pages_with_online_memmap overcounting when
kernelcore=mirror is enabled.

Patch 3 avoids incorrect accounting of pages_with_online_memmap when
subsection holes exist in early sections.

pfn_valid() says early sections always have a full memmap, so even invalid
subsections have a memmap. pfn_to_online_page() says an invalid subsection
cannot be online and its content must be stale. for_each_valid_pfn() follows
pfn_valid() semantics, and we use it to initialize memmap that is not going
to be online and account it as pages_with_online_memmap, which is wrong.

The cleanest approach is to avoid allocating memmap for subsections, which
also removes the special early-section handling from pfn_valid() and
for_each_valid_pfn().

The price is another test_bit(idx, usage->subsection_map) check for early
sections. If that ever becomes a real problem, a future optimization could
cache "full valid section" in a section flag.

Patch 4 introduces pages_with_online_memmap to replace pageblock-by-pageblock
scans across the entire zone for zone contiguity checks

Patch 5 avoids incorrectly shrinking the zone span during memory unplug when
a memory or hole boundary falls in the middle of a subsection.

v3:
    https://lore.kernel.org/linux-mm/20260408031615.1831922-1-yuan1.liu@intel.com/

v4:
    https://lore.kernel.org/linux-mm/20260421125508.2317429-1-yuan1.liu@intel.com/

v4 changes:
  1. Address the pages_with_online_memmap overcounting when kernelcore=mirror

v5 changes:
  1. Rebase onto v7.1-rc3.
  2. Address incorrect pages_with_online_memmap accounting in several cases,
     including kernelcore=mirror, holes in early sections, and incorrect zone
     shrinking.

Yuan Liu (5):
  mm: move mirrored memory overlap checking to the outer loop
  mm: skip non-mirrored ZONE_NORMAL memory map init when
    kernelcore=mirror
  mm: remove the special early-section handling from pfn_valid() and
    for_each_valid_pfn()
  mm/memory_hotplug: optimize zone contiguous check when changing pfn
    range
  mm/memory_hotplug: improve shrink_zone_span() subsection boundary
    checks

 Documentation/mm/physical_memory.rst | 13 +++++
 drivers/base/memory.c                |  6 ++
 include/linux/mmzone.h               | 60 +++++++++++++++++---
 mm/internal.h                        |  8 +--
 mm/memory_hotplug.c                  | 54 +++++++++---------
 mm/mm_init.c                         | 83 +++++++++++-----------------
 mm/sparse-vmemmap.c                  |  4 +-
 7 files changed, 136 insertions(+), 92 deletions(-)

-- 
2.47.3



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

end of thread, other threads:[~2026-06-01  7:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20  9:34 [PATCH v5 0/5] mm/memory_hotplug: optimize zone contiguous check when changing pfn range Yuan Liu
2026-05-20  9:34 ` [PATCH v5 1/5] mm: move mirrored memory overlap checking to the outer loop Yuan Liu
2026-05-21  3:33   ` Wei Yang
2026-05-22  7:43     ` Liu, Yuan1
2026-05-25  8:35       ` Wei Yang
2026-05-20  9:34 ` [PATCH v5 2/5] mm: skip non-mirrored ZONE_NORMAL memory map init when kernelcore=mirror Yuan Liu
2026-05-20  9:34 ` [PATCH v5 3/5] mm: remove the special early-section handling from pfn_valid() and for_each_valid_pfn() Yuan Liu
2026-05-20  9:34 ` [PATCH v5 4/5] mm/memory_hotplug: optimize zone contiguous check when changing pfn range Yuan Liu
2026-05-20  9:34 ` [PATCH v5 5/5] mm/memory_hotplug: improve shrink_zone_span() subsection boundary checks Yuan Liu
2026-05-21  2:59 ` [PATCH v5 0/5] mm/memory_hotplug: optimize zone contiguous check when changing pfn range Wei Yang
2026-05-21  5:16   ` Liu, Yuan1
2026-06-01  7:17 ` Mike Rapoport

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