Re: [PATCH 2/8] mm/memory_hotplug: extract __add_memory_resource() and __offline_memory()

From: Gregory Price

Date: Wed Jan 14 2026 - 12:12:24 EST


On Wed, Jan 14, 2026 at 11:14:21AM +0100, David Hildenbrand (Red Hat) wrote:
> On 1/14/26 09:51, Gregory Price wrote:
> > Extract internal helper functions with explicit parameters to prepare
> > for adding new APIs that allow explicit online type control:
> >
> > - __add_memory_resource(): accepts an explicit online_type parameter.
> > Add MMOP_SYSTEM_DEFAULT as a new value that instructs the function
> > to use mhp_get_default_online_type() for the actual online type.
> > The existing add_memory_resource() becomes a thin wrapper that
> > passes MMOP_SYSTEM_DEFAULT to preserve existing behavior.
> >
> > - __offline_memory(): extracted from offline_and_remove_memory() to
> > handle the offline operation with rollback support. The caller
> > now handles locking and the remove step separately.
>
>
> I don't understand why this change is even part of this patch, can you
> elaborate? You don't add any "explicit parameters to prepare for adding new
> APIs that allow explicit online type control" there.
>
> So likely you squeezed two independent things into a single patch? :)
>
> Likely you should pair the __add_memory_resource() change with the
> add_memory_driver_managed() changed and vice versa.
>

I tried to keep the refactor work and the new feature work separate.

But yeah that's fair i can just add them to the respective path.

> > + /* Use system default online type from mhp_get_default_online_type(). */
> > + MMOP_SYSTEM_DEFAULT,
>
> I don't like having fake options as part of this interface.
>
> Why can't we let selected users use mhp_get_default_online_type() instead?
> Like add_memory_resource(). We can export that function.
>

Wasn't sure if that was preferred, I can do that.

I think i eventually ended up doing that in DAX anyway, I just never
came back around to clean it up.

ack.

~Gregory