Re: [PATCH 5/8] mm/memory_hotplug: add __add_memory_driver_managed() with online_type arg

David Hildenbrand (Arm)
2026-04-13T15:21:18Z

On 3/21/26 16:04, Gregory Price wrote:
> Existing callers of add_memory_driver_managed cannot select the
> preferred online type (ZONE_NORMAL vs ZONE_MOVABLE), requiring it to
> hot-add memory as offline blocks, and then follow up by onlining each
> memory block individually.
>
> Most drivers prefer the system default, but the CXL driver wants to
> plumb a preferred policy through the dax kmem driver.
>
> Refactor APIs to add a new interface which allows the dax kmem and
> cxl_core modules to select a preferred policy. Only expose this
> interface to those modules to avoid confusion among existing API users
> and to limit usage in out-of-tree modules.
>
> Refactor add_memory_driver_managed, extract __add_memory_driver_managed
> - Add proper kernel-doc for add_memory_driver_managed while refactoring
> - New helper accepts an explicit online_type.
> - New help validates online_type is between OFFLINE and ONLINE_MOVABLE
>
> Refactor: add_memory_resource, extract __add_memory_resource
> - new helper accepts an explicit online_type
>
> Original APIs now explicitly pass the system-default to new helpers.
>
> No functional change for existing users.
>

You should add here, that we only allow known in-tree modules to
overwrite the onlining policy (where we know that it's a different
user-requested policy), as we don't want arbitrary OOT drivers to
overwrite the configured system policy.

Therefore EXPORT_SYMBOL_FOR_MODULES().

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

--
Cheers,

David