Re: [PATCH v2 4/5] mm: memory_hotplug: Add memory hotremove probe device

From: Reza Arbab
Date: Mon Dec 04 2017 - 12:50:56 EST


On Fri, Nov 24, 2017 at 02:29:48PM +0000, Andrea Reale wrote:
But, at least in my understanding, the implementation is not as
straightfoward as it looks. If I declare a memory node in the fdt, then,
at boot, the kernel will expect that memory to actually be there to be
used: this is not true if I want to plug my dimms only later at runtime.
So I think that declaring the hotpluggable memory in an fdt memory
node might not feasible without changes.

On the power arch, we do this today using "linux,usable-memory".

memory@10000000000 {
device_type = "memory";
reg = <0x100 0x0 0x0 0x80000000>;
linux,usable-memory = <0x100 0x0 0x0 0x40000000>;
:
}

The reg range defines the node, but at at boot, memblocks are only created for the linux,usable-memory range. The rest can be hotplugged later. YMMV, because this depends on your arch's implementation of memory_add_physaddr_to_nid().

One idea could be to add a new property to memory nodes, to specify what memory is potentially hotplugguable.

Somewhat related, there is already a "hotpluggable" property.

memory@10040000000 {
device_type = "memory";
reg = <0x100 0x40000000 0x0 0x40000000>;
hotpluggable;
:
}

This is subtly different from the earlier example. This memory IS present at boot. The hotpluggable property ensures that it resides in ZONE_MOVABLE so it can potentially be removed.

--
Reza Arbab