[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5e958aaa-b1ac-4512-a592-0e1612032861@redhat.com>
Date: Sat, 21 Dec 2024 16:30:21 +0100
From: David Hildenbrand <david@...hat.com>
To: Gregory Price <gourry@...rry.net>, linux-mm@...ck.org
Cc: linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
loongarch@...ts.linux.dev, kernel-team@...a.com, corbet@....net,
osalvador@...e.de, akpm@...ux-foundation.org, chenhuacai@...nel.org,
kernel@...0n.name, gregkh@...uxfoundation.org, rafael@...nel.org
Subject: Re: [PATCH v3] mm: add build-time option for hotplug memory default
online type
>
> -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 driver managed hotplug memory.
We should call it "hotplugged memory" consistently, which it is from a
pure core-mm perspective ("add memory").
"Driver managed" reminds too much about add_memory_driver_managed(),
which is only one case. Maybe just drop the "e.g., page tables" from the
examples below.
> +
> 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
> + Driver managed memory will not be onlined by default.
"Hotplugged memory"
> + 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
> + memory into the zone it thinks is reasonable. This memory
hotplugged memory
> + may be utilized for kernel data (e.g. page tables).
> +
> +config MHP_DEFAULT_ONLINE_TYPE_ONLINE_KERNEL
> + bool "kernel"
> + help
> + Select this if you want the kernel to automatically online
> + hotplug memory into a zone capable of being used for kernel
> + data (e.g. page tables). 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 (e.g. page tables).
> +
> + 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"
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 3b6f93962481..e3655f07dd6e 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -219,11 +219,30 @@ void put_online_mems(void)
>
> bool movable_node_enabled = false;
>
> -#ifndef CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE
> -int mhp_default_online_type = MMOP_OFFLINE;
> -#else
> -int mhp_default_online_type = MMOP_ONLINE;
> -#endif
> +static int mhp_default_online_type = -1;
> +int mhp_get_default_online_type(void)
> +{
> + if (mhp_default_online_type >= 0)
> + return mhp_default_online_type;
> +
> + if (IS_ENABLED(CONFIG_MHP_DEFAULT_ONLINE_TYPE_OFFLINE))
> + mhp_default_online_type = MMOP_OFFLINE;
> + else if (IS_ENABLED(CONFIG_MHP_DEFAULT_ONLINE_TYPE_ONLINE_AUTO))
> + mhp_default_online_type = MMOP_ONLINE;
> + else if (IS_ENABLED(CONFIG_MHP_DEFAULT_ONLINE_TYPE_ONLINE_KERNEL))
> + mhp_default_online_type = MMOP_ONLINE_KERNEL;
> + else if (IS_ENABLED(CONFIG_MHP_DEFAULT_ONLINE_TYPE_ONLINE_MOVABLE))
> + mhp_default_online_type = MMOP_ONLINE_MOVABLE;
> + else
> + mhp_default_online_type = MMOP_OFFLINE;
What would be nice is if we could use the symbols from Kconfig, to then
only do
mhp_default_online_type = CONFIG_MHP_DEFAULT_ONLINE_TYPE;
But as far as I know, that's not possible.
Thanks!
Acked-by: David Hildenbrand <david@...hat.com>
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists