Re: [PATCH 11/11] nodemask: add cpumask-style operation size bounds

From: Gregory Price (Meta)

Date: Mon Nov 30 2026 - 14:59:45 EST


On 2026-11-27 18:01 -0500, Yury Norov wrote:
> Nodemasks have a compile-time capacity of MAX_NUMNODES, and
> nr_node_ids describes the runtime node ID usage.
>
> Modern distros like Ubuntu default MAX_NUMNODES to 1024, while the
> actual number of nodes is typically smaller. All nodemask operations
> currently refer to the MAX_NUMNODES, which adds a substantial overhead
> on every traversing operation.
>
> Simple switch to the runtime nr_node_ids might hurt users configuring
> their MAX_NUMNODES to reasonable small values because the runtime value
> breaks compile-time optimizations in the underlying bitmap API.
>
> Thus, switch to using small_nodemask_bits, large_nodemask_bits, or
> the precise nr_node_ids, as appropriate.
>
> Bloat-o-meter reports 1-8KB decrease of .text, depending on NR_CPUS
> and MAX_NUMNODES. With nr_node_ids == 2 and MAX_NUMNODES == 1024, basic
> operations like nodes_copy() are ~4x faster
>
> Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>

This breaks cpuset.mems :

2 node host - {0,1}

echo 0-3:1/4 > cpuset.mems
before: succeeds - result: {0}
now: ERANGE

echo 0-1:1/_ > cpuset.mems
before: succeeds - result: {0}
now: {0,1}

i think nodelist_parse probably still needs to use MAX_NUMNODES or the
cpuset code needs a change as well.

But this also has me concerned there are other non-obvious, silent
changes this patch produces.

--
~Gregory