[PATCH v3 00/11] mm/memory_hotplug: Shrink zones before removing memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is the successor of "[PATCH v2 0/6] mm/memory_hotplug: Consider all
zones when removing memory". I decided to go one step further and finally
factor out the shrinking of zones from memory removal code. Zones are now
fixed up when offlining memory/onlining of memory fails/before removing
ZONE_DEVICE memory.

I guess only patch #1 is debatable - it is certainly not a blocker for
the other stuff in this series, it just doesn't seem to be 100% safe. I
am not quite sure if we have a real performance issue here, let's hear
what people think.

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

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

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

This series fixes various issues:
1. Memory removal can currently crash the system in case the first
memory block was never onlined.

2. Zone shrinking code can crash the system when trying to look at
uninitialized memmaps.

3. Removing memory with different/multiple/no zones for affected memory
blocks does not properly shring zones. It really only works correcty in the
case all memory blocks were onlined to the same zone.

4. In case memory onlining fails, the zones are not fixed up again.

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

For !ZONE_DEVICE memory, zones are now fixed up when offlining memory. This
now works very reliable.

For ZONE_DEVICE memory, the zone is fixed up before removing memory. I
haven't tested it, but we should no longer be able to crash the system
BUT there is a fundamental issue remaining that has to be sorted out next:
How to detect which memmaps of ZONE_DEVICE memory is valid. The current
fix I implemented is ugly and has to go.

For !ZONE_DEVICE memory we can look at the SECTION_IS_ONLINE flag to
decide whether the memmap was initialized. We can't easily use the same for
ZONE_DEVICE memory, especially, because we have subsection hotplug there.
While we have "present" masks for subsections ("memory was added") we don't
have something similar for "online/active". This could probably be one
thing to look into in the future: Use SECTION_IS_ONLINE also for
ZONE_DEVICE memory and remember in a subsection bitmap which subsections
are actually online/active.

I'll leave that exercise to the ZONE_DEVICE folks. From a memory block
onlining/offlining point of view things should be clean now.

While we could still have false positives for ZONE_DEVICE memory when
trying to shrink zones, we should no longer crash - which improves
the situation heavily.

Fact: set_zone_contiguous() is even more broken (false positives) for
ZONE_DEVICE memory: it will never set a zone contiguous because we are
missing the exact same functionality: How to detect whether a memmap was
initialized, so we can trust the zone values.

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

A bunch of prepararions and cleanups included. I only tested on x86
with DIMMs so far.

Cc: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>

David Hildenbrand (11):
  mm/memremap: Get rid of memmap_init_zone_device()
  mm/memory_hotplug: Simplify shrink_pgdat_span()
  mm/memory_hotplug: We always have a zone in
    find_(smallest|biggest)_section_pfn
  mm/memory_hotplug: Drop local variables in shrink_zone_span()
  mm/memory_hotplug: Optimize zone shrinking code when checking for
    holes
  mm/memory_hotplug: Fix crashes in shrink_zone_span()
  mm/memory_hotplug: Exit early in __remove_pages() on BUGs
  mm: Exit early in set_zone_contiguous() if already contiguous
  mm/memory_hotplug: Remove pages from a zone before removing memory
  mm/memory_hotplug: Remove zone parameter from __remove_pages()
  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 |   9 +-
 include/linux/mm.h             |   4 +-
 mm/memory_hotplug.c            | 215 +++++++++++++++------------------
 mm/memremap.c                  |  19 +--
 mm/page_alloc.c                |  45 +++----
 12 files changed, 136 insertions(+), 183 deletions(-)

-- 
2.21.0





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux