Re: [PATCH 04/11] mm/mempolicy: preserve full-width userspace nodemasks
From: David Hildenbrand (Arm)
Date: Thu Dec 03 2026 - 03:06:56 EST
[...]
>>> + /* Relative indices can exceed the runtime node ID limit. */
>>> + __nodes_fold(&tmp, orig, nodes_weight(*rel), MAX_NUMNODES);
>>
>> This is a bit shaky. It means that we can silently introduce new issues by using
>> the "obvious" helper.
>
> That's why the comment is there. Using double-underscored alternative
> for some helper is never obvious IMO.
Yes, and comments work around the underlying issue IMHO that we have valid use
cases that must do something different for correctness.
>
>> Maybe we should just have a set of helpers for these cases
>>
>> __nodes_fold(&tmp, orig, nodes_weight(*rel), MAX_NUMNODES);
>> __nodes_empty(nodes, MAX_NUMNODES
>> __nodes_clear(nodes, MAX_NUMNODES)
>> ...
>>
>> that embed in their name what they should be used for (I assume, whenever we are
>> interacting with user-space)?
>
> There's 6 direct users of the underscored API in the kernel, all in
> mm/mempolicy.c. Let's maybe introduce something like
>
> mm_usernodes_fold()
>
> in mempolicy.h? If there's more users, we can always move the helpers
> to the system-wide header. LMK what do you think?
Something like that sounds much better to me. If it avoids the comments then
it's self documenting. But let's do that consistently for all helpers we need
here. Should be trivial to add.
But let's also hear what others think.
--
Cheers,
David