On 6/9/26 17:35, Gregory Price wrote:
> On Tue, Jun 09, 2026 at 12:26:07PM +0200, David Hildenbrand (Arm) wrote:
>> On 6/5/26 23:19, Gregory Price wrote:
>>
>>>
>>> +static int dax_kmem_parse_state(const char *buf)
>>> +{
>>> + if (sysfs_streq(buf, "unplugged"))
>>> + return DAX_KMEM_UNPLUGGED;
>>> + if (sysfs_streq(buf, "online"))
>>> + return MMOP_ONLINE;
>>> + if (sysfs_streq(buf, "online_kernel"))
>>> + return MMOP_ONLINE_KERNEL;
>>> + if (sysfs_streq(buf, "online_movable"))
>>> + return MMOP_ONLINE_MOVABLE;
>>> + return -EINVAL;
>>
>> Should we try making use of mhp_online_type_from_str()/online_type_to_str()
>> [possibly a nicer exported function for the latter] to avoid duplicating
>> this ...
>>
>
> In patch 6 response i point out adding MMOP_UNPLUGGED
>
> If we add MMOP_UNPLUGGED as a state that is only use by callers of
> memory hotplug to represent the current state - but not as a valid input
> to memory_hotplug.c - then we can simply this as you request.
>
> Although we'll need to add a couple lines to memoryN/state parsing code
> to disallow MMOP_UNPLUGGED as a valid input (otherwise you could
> permanently unplug memory without the ability to get it back... unless
> you want that? Seems useless to me.)
I would just special-case your KMEM-special value, and then branch off to the
core helpers?
static int dax_kmem_parse_state(const char *buf)
{
if (sysfs_streq(buf, "unplugged"))
return DAX_KMEM_UNPLUGGED;
return mhp_online_type_from_str(...);
}
So there is no need to add a value to MM core?
--
Cheers,
David