[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3424eba7-523b-4351-abd0-3a888a3e5e61@kernel.org>
Date: Wed, 4 Feb 2026 22:08:45 +0100
From: "David Hildenbrand (arm)" <david@...nel.org>
To: Gregory Price <gourry@...rry.net>,
Jonathan Cameron <jonathan.cameron@...wei.com>
Cc: linux-mm@...ck.org, linux-cxl@...r.kernel.org, nvdimm@...ts.linux.dev,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, kernel-team@...a.com, dave@...olabs.net,
dave.jiang@...el.com, alison.schofield@...el.com, vishal.l.verma@...el.com,
ira.weiny@...el.com, dan.j.williams@...el.com, willy@...radead.org,
jack@...e.cz, terry.bowman@....com, john@...alactic.com,
Oscar Salvador <osalvador@...e.de>, Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 2/9] mm/memory_hotplug: add __add_memory_driver_managed()
with online_type arg
On 2/2/26 22:37, Gregory Price wrote:
> On Mon, Feb 02, 2026 at 06:46:09PM +0000, Jonathan Cameron wrote:
>>>
>>> I can add a cleanup-patch prior to use the enum, but i don't think this
>>> actually enables the compiler to do anything new at the moment?
>>
>> Good point. More coffee needed (or sleep)
>>
>> It lets sparse do some checking, but sadly only for wrong enum assignment.
>> (Gcc has -Wenum-conversion as well which I think is effectively the same)
>> I.e. you can't assign a value from a different enum without casting.
>>
>> It can't do anything if people just pass in an out of range int.
>>
>
> Which, after looking a bit... mm/memory_hotplug.c does this quite a bit
> internally - except it uses a uint8_t
>
> Example:
>
> static int try_offline_memory_block(struct memory_block *mem, void *arg)
> {
> uint8_t online_type = MMOP_ONLINE_KERNEL;
> uint8_t **online_types = arg;
> ... snip ...
> }
>
> int offline_and_remove_memory(u64 start, u64 size)
> {
> uint8_t *online_types, *tmp;
> ... snip ...
> online_types = kmalloc_array(mb_count, sizeof(*online_types),
> GFP_KERNEL);
> }
>
> So that's fun.
>
> I'm not sure it's worth the churn here, but happy to do it if there are
> strong opinions.
>
> ---
>
> David do you have thoughts here?
I guess we should clean that all up where easily possible, but I don't
expect you to do that.
For online_types I used it, obviously, to save memory. So I'd expect it
to stay at least there, but cast it to the proper type once we take it
out the array.
--
Cheers,
David
Powered by blists - more mailing lists