Re: [PATCH 1/8] mm/memory_hotplug: pass online_type to online_memory_block() via arg

From: David Hildenbrand (Red Hat)

Date: Wed Jan 14 2026 - 04:46:09 EST


On 1/14/26 09:51, Gregory Price wrote:
Modify online_memory_block() to accept the online type through its arg
parameter rather than calling mhp_get_default_online_type() internally.
This prepares for allowing callers to specify explicit online types.

Update the caller in add_memory_resource() to pass the default online
type via a local variable. No functional change.

Signed-off-by: Gregory Price <gourry@xxxxxxxxxx>
---
mm/memory_hotplug.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 389989a28abe..5718556121f0 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1337,7 +1337,9 @@ static int check_hotplug_memory_range(u64 start, u64 size)
static int online_memory_block(struct memory_block *mem, void *arg)
{
- mem->online_type = mhp_get_default_online_type();
+ int *online_type = arg;
+
+ mem->online_type = *online_type;
return device_online(&mem->dev);
}
@@ -1578,8 +1580,12 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
merge_system_ram_resource(res);
/* online pages if requested */
- if (mhp_get_default_online_type() != MMOP_OFFLINE)
- walk_memory_blocks(start, size, NULL, online_memory_block);
+ if (mhp_get_default_online_type() != MMOP_OFFLINE) {
+ int online_type = mhp_get_default_online_type();
+
+ walk_memory_blocks(start, size, &online_type,
+ online_memory_block);

I think you could just pass the value by casting to uintptr_t and back. Doesn't make a big difference here, though.

Acked-by: David Hildenbrand (Red Hat) <david@xxxxxxxxxx>

--
Cheers

David