Skip to content

memory-hotplug: hot-remove physical memory

Yasuaki Ishimatsu linux-acpi linux-ia64 linux-mm linux-s390 linux-sh linuxppc-dev lkml sparclinux 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 19 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10memory-hotplug : check whether memory is offline or not when removing memorydrivers/base/memory.c include/linux/memory.h mm/memory_hotplug.c+59 -25 replies
2/10memory-hotplug : remove /sys/firmware/memmap/X sysfsdrivers/firmware/memmap.c include/linux/firmware-map.h mm/memory_hotplug.c+108 -32 replies
3/10memory-hotplug : introduce new function arch_remove_memory() for removing page table depends on architecturearch/ia64/mm/init.c arch/powerpc/mm/mem.c arch/s390/mm/init.c +6 more+96 -00 replies
4/10memory-hotplug : unregister memory section on SPARSEMEM_VMEMMAPmm/memory_hotplug.c+8 -50 replies
5/10memory-hotplug : memory-hotplug: check page type in get_page_bootmemmm/memory_hotplug.c+11 -43 replies
6/10memory-hotplug : implement register_page_bootmem_info_section of sparse-vmemmaparch/ia64/mm/discontig.c arch/powerpc/mm/init_64.c arch/s390/mm/vmem.c +5 more+113 -140 replies
7/10memory-hotplug : remove memmap of sparse-vmemmaparch/ia64/mm/discontig.c arch/powerpc/mm/init_64.c arch/s390/mm/vmem.c +5 more+158 -170 replies
8/10memory-hotplug : remove page table of x86_64 architecturearch/x86/include/asm/pgtable_types.h arch/x86/mm/init_64.c arch/x86/mm/pageattr.c+173 -227 replies
9/10memory-hotplug : memory_hotplug: clear zone when removing the memorymm/memory_hotplug.c+207 -00 replies
10/10memory-hotplug : remove sysfs file of nodemm/memory_hotplug.c+54 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/10] memory-hotplug: hot-remove physical memory

The patch-set was divided from following thread's patch-set.

https://lkml.org/lkml/2012/9/5/201

If you want to know the reason, please read following thread.

https://lkml.org/lkml/2012/10/2/83

The patch-set has only the function of kernel core side for physical memory hot remove. So if you use the patch, please apply following patches.

- bug fix for memory hot remove
https://lkml.org/lkml/2012/9/27/39
https://lkml.org/lkml/2012/10/2/83
http://www.spinics.net/lists/linux-mm/msg42982.html

- acpi framework
https://lkml.org/lkml/2012/10/3/126
https://lkml.org/lkml/2012/10/3/641

The patches can free/remove the following things:

- /sys/firmware/memmap/X/{end, start, type} : [PATCH 2/10]

  - mem_section and related sysfs files       : [PATCH 3-4/10]
  - memmap of sparse-vmemmap                  : [PATCH 5-7/10]
  - page table of removed memory              : [RFC PATCH 8/10]
  - node and related sysfs files              : [RFC PATCH 9-10/10]

* [PATCH 1/10] checks whether the memory can be removed or not.

If you find lack of function for physical memory hot-remove, please let me know.

How to test this patchset?
1. apply this patchset and build the kernel. MEMORY_HOTPLUG, MEMORY_HOTREMOVE, ACPI_HOTPLUG_MEMORY must be selected.
2. load the module acpi_memhotplug
3. hotplug the memory device(it depends on your hardware)
You will see the memory device under the directory /sys/bus/acpi/devices/. Its name is PNP0C80:XX.
4. online/offline pages provided by this memory device
You can write online/offline to /sys/devices/system/memory/memoryX/state to online/offline pages provided by this memory device
5. hotremove the memory device
You can hotremove the memory device by the hardware, or writing 1 to /sys/bus/acpi/devices/PNP0C80:XX/eject.

Note: if the memory provided by the memory device is used by the kernel, it can't be offlined. It is not a bug.

Known problems:
1. memory can't be offlined when CONFIG_MEMCG is selected.
For example: there is a memory device on node 1. The address range is [1G, 1.5G). You will find 4 new directories memory8, memory9, memory10, and memory11 under the directory /sys/devices/system/memory/.
If CONFIG_MEMCG is selected, we will allocate memory to store page cgroup when we online pages. When we online memory8, the memory stored page cgroup is not provided by this memory device. But when we online memory9, the memory stored page cgroup may be provided by memory8. So we can't offline memory8 now. We should offline the memory in the reversed order.
When the memory device is hotremoved, we will auto offline memory provided by this memory device. But we don't know which memory is onlined first, so offlining memory may fail. In such case, you should offline the memory by hand before hotremoving the memory device.
2. hotremoving memory device may cause kernel panicked
This bug will be fixed by Liu Jiang's patch:
https://lkml.org/lkml/2012/7/3/1