This patchset provides a new interface for dynamic configuration and deconfiguration of hotplug memory, allowing for mixed altmap and non-altmap support. It is a follow-up on the discussion with David, when introducing memmap_on_memory support for s390: https://lore.kernel.org/all/ee492da8-74b4-4a97-8b24-73e07257f01d@xxxxxxxxxx/ The following suggestions from that discussion are addressed: * "Look into a proper interface to add/remove memory instead of relying on online/offline ... (e.g., where user don't want an altmap because of fragmentation)" With the new interface, users can dynamically specify which memory ranges should have altmap support, rather than having it statically enabled or disabled for all hot-plugged memory. It would also be possible to revert the MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers, that were previously added for s390, and move that part to the new interface handler. This is not yet done in this series, and might also need further evaluation, e.g. we would lose the memmap_on_memory feature for s390, when the new interface config option is not selected. * "Support variable-sized memory blocks long-term, or simulate that by "grouping" memory blocks that share a same altmap located on the first memory blocks in that group. On s390x that adds all memory ahead of time, it's hard to make a decision what the right granularity will be. The user can give better hints when adding/removing memory explicitly." With the new interface, the user could specify a memory range, including multiple blocks, and whether he wants altmap support for that range. This could allow for the mentioned altmap block grouping, or even variable-sized blocks, in the future. When the new interface is enabled, s390 will not add all possible hotplug memory in advance, like before, to make it visible in sysfs for online/offline actions. Instead, a new "max_configurable" sysfs attribute will give a hint on the presence of hotplug memory. Before it can be set online, it has to be configured via a new interface in /sys/bus/memory/devices/configure_memory, basically imitating what is done in ACPI handlers for other archs. Usage format for the new interface: echo config_mode,memoryrange,altmap_mode > /sys/bus/memory/devices/configure_memory E.g. to configure a range with altmap: echo 1,0x200000000-0x20fffffff,1 > /sys/bus/memory/devices/configure_memory lsmem/chmem tools can be adjusted to do all that transparently, so that there would be no visible impact to the user, at least not when using those tools. In addition, support for dynamic altmap configuration can be added to those tools. This could not only help to make s390 more flexible and similar to others (wrt adding hotplug memory in advance). It might also be possible to provide the dynamically configured altmap support for others. E.g. instead of directly doing an add_memory() in the ACPI handler, with the static altmap setting, you could instead defer that to the new interface which allows dynamic altmap configuration. Patch 1 provides necessary validation against user inputs for new /sys/bus/memory/devices/configure_memory sysfs interface. Patch 2 displays altmap support per memory block. CONFIG_RUNTIME_MEMORY_CONFIGURATION enables dynamic addition of memory with altmap/non-altmap support. Hence, providing concrete altmap information would be beneficial. Patch 3 adds /sys/devices/system/memory/max_configurable sysfs show interface to list maximum number of possible memory block supported by the architecture. This information would be beneficial for tools like lsmem to distinguish betweeen configured memory blocks and deconfigured memory blocks. Patch 4 provides support for both legacy boottime standby memory configuration or runtime configuration of standby memory. The patch also validates user inputs against /sys/bus/memory/devices/configure_memory interface and overrides /sys/devices/system/memory/max_configurable value. Thank you. Sumanth Korikkar (4): mm/memory_hotplug: Add interface for runtime (de)configuration of memory mm/memory_hotplug: Add memory block altmap sysfs attribute mm/memory_hotplug: Add max_configurable sysfs read attribute s390/sclp: Add support for dynamic (de)configuration of memory drivers/base/memory.c | 153 +++++++++++++++++++++++++++++++++++ drivers/s390/char/sclp_cmd.c | 80 +++++++++++++++--- include/linux/memory.h | 6 ++ mm/Kconfig | 16 ++++ 4 files changed, 246 insertions(+), 9 deletions(-) -- 2.45.2