Re: [PATCH v2 4/5] dax/kmem: add sysfs interface for runtime hotplug state control
From: Andrew Morton
Date: Tue Jan 27 2026 - 16:31:58 EST
On Wed, 14 Jan 2026 18:50:20 -0500 Gregory Price <gourry@xxxxxxxxxx> wrote:
> The dax kmem driver currently onlines memory automatically during
> probe using the system's default online policy but provides no way
> to control or query the entire region state at runtime.
>
> There is no atomic to offline and remove memory blocks together.
>
> Add a new 'hotplug' sysfs attribute that allows userspace to control
> and query the entire memory region state.
>
> The interface supports the following states:
> - "unplug": memory is offline and blocks are not present
> - "online": memory is online as normal system RAM
> - "online_movable": memory is online in ZONE_MOVABLE
>
> Valid transitions:
> - unplugged -> online
> - unplugged -> online_movable
> - online -> unplugged
> - online_movable -> unplugged
>
> "offline" (memory blocks exist but are offline by default) is not
> supported because it's functionally equivalent to "unplugged" and
> entices races between offlining and unplugging.
>
> The initial state after probe uses mhp_get_default_online_type() to
> preserve backwards compatibility - existing systems with auto-online
> policies will continue to work as before.
>
> As with any hot-remove mechanism, the removal can fail and if rollback
> fails the system can be left in an inconsistent state.
>
> Unbind Note:
> We used to call remove_memory() during unbind, which would fire a
> BUG() if any of the memory blocks were online at that time. We lift
> this into a WARN in the cleanup routine and don't attempt hotremove
> if ->state is not DAX_KMEM_UNPLUGGED.
>
> The resources are still leaked but this prevents deadlock on unbind
> if a memory region happens to be impossible to hotremove.
>
> ...
>
> --- a/Documentation/ABI/testing/sysfs-bus-dax
> +++ b/Documentation/ABI/testing/sysfs-bus-dax
> @@ -151,3 +151,20 @@ Description:
> memmap_on_memory parameter for memory_hotplug. This is
> typically set on the kernel command line -
> memory_hotplug.memmap_on_memory set to 'true' or 'force'."
> +
> +What: /sys/bus/dax/devices/daxX.Y/hotplug
> +Date: January, 2026
> +KernelVersion: v6.21
> +Contact: nvdimm@xxxxxxxxxxxxxxx
> +Description:
> + (RW) Controls what hotplug state of the memory region.
s/what// ?
Maybe "Controls hotplug state of a dax memory region".
> + Applies to all memory blocks associated with the device.
> + Only applies to dax_kmem devices.
> +
> + States: [unplugged, online, online_movable]
> + Arguments:
> + "unplug": memory is offline and blocks are not present
> + "online": memory is online as normal system RAM
> + "online_movable": memory is online in ZONE_MOVABLE
> +
This is perhaps a little brief? Is there more we can tell users about
what this is and how it behaves and why they might want to use it?