Re: [PATCH v7 04/10] mm/memory_hotplug: export mhp_get_default_online_type

[email protected] Sun, 12 Jul 2026 15:56:18 +0000
Newsgroups dev.linux.lists.nvdimm,org.kernel.vger.linux-cxl
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] add_memory_resource() caches mhp_get_default_online_type() at the start but re-reads it for the final condition check, potentially ignoring concurrent sysfs policy changes.
--

--- Patch [4]: [PATCH v7 04/10] mm/memory_hotplug: export mhp_get_default_online_type ---
commit d037ee754b46e2d238e974dbf3f6ebb2ab7882bc
Author: Gregory Price <[email protected]>

mm/memory_hotplug: export mhp_get_default_online_type

Drivers which may pass hotplug policy down to DAX need MMOP_ symbols
and the mhp_get_default_online_type function for hotplug use cases.
This commit exports mhp_get_default_online_type to allow these drivers
to build when hotplug is disabled and still use the DAX use case.

[ ... ]

> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 6833208cc17cb..4942570540956 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -239,6 +239,7 @@ enum mmop mhp_get_default_online_type(void)
>  
>  	return mhp_default_online_type;
>  }
> +EXPORT_SYMBOL_GPL(mhp_get_default_online_type);

[Severity: Medium]
In add_memory_resource(), mhp_get_default_online_type() is cached at the
start of the function, but then re-read for the final condition check:

mm/memory_hotplug.c:add_memory_resource() {
	enum mmop online_type = mhp_get_default_online_type();
...
	/* online pages if requested */
	if (mhp_get_default_online_type() != MMOP_OFFLINE)
		walk_memory_blocks(start, size, &online_type,
				   online_memory_block);
}

If a system administrator modifies the auto-online sysfs policy concurrently
while a memory hot-add operation is in progress, could this re-read cause
the operation to silently ignore the user's explicit online policy
(e.g., online_movable), onlining the memory into the default zone instead?

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=4