From: David Hildenbrand <david@redhat.com>
To: Gregory Price <gourry@gourry.net>, linux-mm@kvack.org
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
loongarch@lists.linux.dev, kernel-team@meta.com, corbet@lwn.net,
osalvador@suse.de, akpm@linux-foundation.org,
chenhuacai@kernel.org, kernel@xen0n.name,
gregkh@linuxfoundation.org, rafael@kernel.org
Subject: Re: [PATCH v3] mm: add build-time option for hotplug memory default online type
Date: Sat, 21 Dec 2024 16:30:21 +0100 [thread overview]
Message-ID: <5e958aaa-b1ac-4512-a592-0e1612032861@redhat.com> (raw)
In-Reply-To: <20241220210709.300066-1-gourry@gourry.net>
>
> -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@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-12-21 15:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 21:07 Gregory Price
2024-12-21 15:30 ` David Hildenbrand [this message]
2024-12-22 5:03 ` Gregory Price
2025-01-02 11:35 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5e958aaa-b1ac-4512-a592-0e1612032861@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=chenhuacai@kernel.org \
--cc=corbet@lwn.net \
--cc=gourry@gourry.net \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-team@meta.com \
--cc=kernel@xen0n.name \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=loongarch@lists.linux.dev \
--cc=osalvador@suse.de \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox