Skip to content

mm/memory_hotplug: Shrink zones before removing memory

David Hildenbrand linux-arm-kernel linux-ia64 linux-mm linux-s390 linux-sh linuxppc-dev lkml 4 versions – Applied

Status from this message: [merged] mm-memory_hotplug-cleanup-__remove_pages.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest10 patches 64 repliesApplied 10/10
  2. v510 patches 9 repliesSuperseded
  3. v48 patches 8 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v311 patches10 repliesSuperseded

Changes in v6 from the cover letter

- "mm/memunmap: Don't access uninitialized memmap in memunmap_pages()" -- Minimize code changes, rephrase subject and description
- "mm/memory_hotplug: Don't access uninitialized memmaps in shrink_zone_span()" -- Add ifdef to make it compile without ZONE_DEVICE

Patches in v6 All 10 applied

#Subject and filesSizeRepliesApplied
1/10mm/memunmap: Don't access uninitialized memmap in memunmap_pages()mm/memremap.c+7 -43 repliesApplied
2/10mm/memmap_init: Update variable name in memmap_init_zonemm/page_alloc.c+4 -40 repliesApplied
3/10mm/memory_hotplug: Don't access uninitialized memmaps in shrink_pgdat_span()mm/memory_hotplug.c+15 -571 replyApplied
4/10mm/memory_hotplug: Don't access uninitialized memmaps in shrink_zone_span()mm/memory_hotplug.c+13 -34 repliesApplied
5/10mm/memory_hotplug: Shrink zones when offlining memoryarch/arm64/mm/mmu.c arch/ia64/mm/init.c arch/powerpc/mm/mem.c +7 more+29 -389 repliesApplied
6/10mm/memory_hotplug: Poison memmap in remove_pfn_range_from_zone()mm/memory_hotplug.c mm/memremap.c+5 -02 repliesApplied
7/10mm/memory_hotplug: We always have a zone in find_(smallest|biggest)_section_pfnmm/memory_hotplug.c+2 -24 repliesApplied
8/10mm/memory_hotplug: Don't check for "all holes" in shrink_zone_span()mm/memory_hotplug.c+7 -2720 repliesApplied
9/10mm/memory_hotplug: Drop local variables in shrink_zone_span()mm/memory_hotplug.c+6 -93 repliesApplied
10/10mm/memory_hotplug: Cleanup __remove_pages()mm/memory_hotplug.c+6 -119 repliesApplied

Reviews trailers per patch

7 of 10 patches have a Reviewed-by or Acked-by.

PatchPankaj GuptaDavid HildenbrandOscar SalvadorWei Yang
1/10
2/10R-b R-b
3/10
4/10
5/10R-b
6/10R-b
7/10R-b R-b
8/10R-b
9/10R-b R-b
10/10R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v6 thread

Cover letter [PATCH v6 00/10] mm/memory_hotplug: Shrink zones before removing memory

This series fixes the access of uninitialized memmaps when shrinking zones/nodes and when removing memory. Also, it contains all fixes for crashes that can be triggered when removing certain namespace using memunmap_pages() - ZONE_DEVICE, reported by Aneesh.

We stop trying to shrink ZONE_DEVICE, as it's buggy, fixing it would be more involved (we don't have SECTION_IS_ONLINE as an indicator), and shrinking is only of limited use (set_zone_contiguous() cannot detect the ZONE_DEVICE as contiguous).

We continue shrinking !ZONE_DEVICE zones, however, I reduced the amount of code to a minimum. Shrinking is especially necessary to keep zone->contiguous set where possible, especially, on memory unplug of DIMMs at zone boundaries.

--------------------------------------------------------------------------

Zones are now properly shrunk when offlining memory blocks or when onlining failed. This allows to properly shrink zones on memory unplug even if the separate memory blocks of a DIMM were onlined to different zones or re-onlined to a different zone after offlining.

Example:

:/# cat /proc/zoneinfo
Node 1, zone  Movable
        spanned  0
        present  0
        managed  0
:/# echo "online_movable" > /sys/devices/system/memory/memory41/state
:/# echo "online_movable" > /sys/devices/system/memory/memory43/state
:/# cat /proc/zoneinfo
Node 1, zone  Movable
        spanned  98304
        present  65536
        managed  65536
:/# echo 0 > /sys/devices/system/memory/memory43/online
:/# cat /proc/zoneinfo
Node 1, zone  Movable
        spanned  32768
        present  32768
        managed  32768
:/# echo 0 > /sys/devices/system/memory/memory41/online
:/# cat /proc/zoneinfo
Node 1, zone  Movable
        spanned  0
        present  0
        managed  0

--------------------------------------------------------------------------

I tested this with DIMMs on x86. I didn't test the ZONE_DEVICE part.

v4 -> v6:
- "mm/memunmap: Don't access uninitialized memmap in memunmap_pages()" -- Minimize code changes, rephrase subject and description
- "mm/memory_hotplug: Don't access uninitialized memmaps in shrink_zone_span()" -- Add ifdef to make it compile without ZONE_DEVICE

v4 -> v5:
- "mm/memory_hotplug: Don't access uninitialized memmaps in shrink_zone_span()" -- Add more details why ZONE_DEVICE is special
- Include two patches from Aneesh
-- "mm/memunmap: Use the correct start and end pfn when removing pages
from zone"
-- "mm/memmap_init: Update variable name in memmap_init_zone"

v3 -> v4:
- Drop "mm/memremap: Get rid of memmap_init_zone_device()"
-- As Alexander noticed, it was messy either way
- Drop "mm/memory_hotplug: Exit early in __remove_pages() on BUGs"
- Drop "mm: Exit early in set_zone_contiguous() if already contiguous"
- Drop "mm/memory_hotplug: Optimize zone shrinking code when checking for holes"
- Merged "mm/memory_hotplug: Remove pages from a zone before removing memory" and "mm/memory_hotplug: Remove zone parameter from __remove_pages()" into "mm/memory_hotplug: Shrink zones when offlining memory"
- Added "mm/memory_hotplug: Poison memmap in remove_pfn_range_from_zone()"
- Stop shrinking ZONE_DEVICE
- Reshuffle patches, moving all fixes to the front. Add Fixes: tags.
- Change subject/description of various patches
- Minor changes (too many to mention)

Cc Aneesh Kumar K.V <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Dan Williams <[email protected]>
Cc Michal Hocko <[email protected]>

Aneesh Kumar K.V (2):
mm/memunmap: Don't access uninitialized memmap in memunmap_pages() mm/memmap_init: Update variable name in memmap_init_zone

David Hildenbrand (8):
mm/memory_hotplug: Don't access uninitialized memmaps in
shrink_pgdat_span()
mm/memory_hotplug: Don't access uninitialized memmaps in
shrink_zone_span()
mm/memory_hotplug: Shrink zones when offlining memory mm/memory_hotplug: Poison memmap in remove_pfn_range_from_zone() mm/memory_hotplug: We always have a zone in
find_(smallest|biggest)_section_pfn
mm/memory_hotplug: Don't check for "all holes" in shrink_zone_span() mm/memory_hotplug: Drop local variables in shrink_zone_span() mm/memory_hotplug: Cleanup __remove_pages()

 arch/arm64/mm/mmu.c            |   4 +-
 arch/ia64/mm/init.c            |   4 +-
 arch/powerpc/mm/mem.c          |   3 +-
 arch/s390/mm/init.c            |   4 +-
 arch/sh/mm/init.c              |   4 +-
 arch/x86/mm/init_32.c          |   4 +-
 arch/x86/mm/init_64.c          |   4 +-
 include/linux/memory_hotplug.h |   7 +-
 mm/memory_hotplug.c            | 186 ++++++++++++---------------------
 mm/memremap.c                  |  13 ++-
 mm/page_alloc.c                |   8 +-
 11 files changed, 90 insertions(+), 151 deletions(-)
Signature · 1 line
2.21.0