mm: add build-time option for hotplug memory default online type

Memory hotplug presently auto-onlines memory into a zone the kernel deems
appropriate if CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y.

The memhp_default_state boot param enables runtime config, but it's not
possible to do this at build-time.

Remove CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE, and replace it with
CONFIG_MHP_DEFAULT_ONLINE_TYPE_* choices that sync with the boot param.

Selections:
  CONFIG_MHP_DEFAULT_ONLINE_TYPE_OFFLINE
    => mhp_default_online_type = "offline"
       Memory will not be onlined automatically.

  CONFIG_MHP_DEFAULT_ONLINE_TYPE_ONLINE_AUTO
    => mhp_default_online_type = "online"
       Memory will be onlined automatically in a zone deemed.
       appropriate by the kernel.

  CONFIG_MHP_DEFAULT_ONLINE_TYPE_ONLINE_KERNEL
    => mhp_default_online_type = "online_kernel"
       Memory will be onlined automatically.
       The zone may allow kernel data (e.g. ZONE_NORMAL).

  CONFIG_MHP_DEFAULT_ONLINE_TYPE_ONLINE_MOVABLE
    => mhp_default_online_type = "online_movable"
       Memory will be onlined automatically.
       The zone will be ZONE_MOVABLE.

Default to CONFIG_MHP_DEFAULT_ONLINE_TYPE_OFFLINE to match the existing
default CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=n behavior.

Existing users of CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y should use
CONFIG_MHP_DEFAULT_ONLINE_TYPE_ONLINE_AUTO.

[gourry@gourry.net: update KConfig comments]
  Link: https://lkml.kernel.org/r/20241226182918.648799-1-gourry@gourry.net
Link: https://lkml.kernel.org/r/20241220210709.300066-1-gourry@gourry.net
Signed-off-by: Gregory Price <gourry@gourry.net>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Gregory Price
2024-12-20 16:07:09 -05:00
committed by Andrew Morton
parent 901083d8f5
commit 44d46b76c3
7 changed files with 89 additions and 23 deletions

View File

@@ -550,20 +550,63 @@ menuconfig MEMORY_HOTPLUG
if MEMORY_HOTPLUG
config MEMORY_HOTPLUG_DEFAULT_ONLINE
bool "Online the newly added memory blocks by default"
depends on MEMORY_HOTPLUG
choice
prompt "Memory Hotplug Default Online Type"
default MHP_DEFAULT_ONLINE_TYPE_OFFLINE
help
Default memory type for hotplugged memory.
This option sets the default policy setting for memory hotplug
onlining policy (/sys/devices/system/memory/auto_online_blocks) which
determines what happens to newly added memory regions. Policy setting
can always be changed at runtime.
The default is 'offline'.
Select offline to defer onlining to drivers and user policy.
Select auto to let the kernel choose what zones to utilize.
Select online_kernel to generally allow kernel usage of this memory.
Select online_movable to generally disallow kernel usage of this memory.
Example kernel usage would be page structs and page tables.
See Documentation/admin-guide/mm/memory-hotplug.rst for more information.
Say Y here if you want all hot-plugged memory blocks to appear in
'online' state by default.
Say N here if you want the default policy to keep all hot-plugged
memory blocks in 'offline' state.
config MHP_DEFAULT_ONLINE_TYPE_OFFLINE
bool "offline"
help
Hotplugged memory will not be onlined by default.
Choose this for systems with drivers and user policy that
handle onlining of hotplug memory policy.
config MHP_DEFAULT_ONLINE_TYPE_ONLINE_AUTO
bool "auto"
help
Select this if you want the kernel to automatically online
hotplugged memory into the zone it thinks is reasonable.
This memory may be utilized for kernel data.
config MHP_DEFAULT_ONLINE_TYPE_ONLINE_KERNEL
bool "kernel"
help
Select this if you want the kernel to automatically online
hotplugged memory into a zone capable of being used for kernel
data. This typically means ZONE_NORMAL.
config MHP_DEFAULT_ONLINE_TYPE_ONLINE_MOVABLE
bool "movable"
help
Select this if you want the kernel to automatically online
hotplug memory into ZONE_MOVABLE. This memory will generally
not be utilized for kernel data.
This should only be used when the admin knows sufficient
ZONE_NORMAL memory is available to describe hotplug memory,
otherwise hotplug memory may fail to online. For example,
sufficient kernel-capable memory (ZONE_NORMAL) must be
available to allocate page structs to describe ZONE_MOVABLE.
endchoice
config MEMORY_HOTREMOVE
bool "Allow for memory hot remove"