Re: [PATCH 01/11] nodemask: add 'small' and 'large' compile-time sizes

From: David Hildenbrand (Arm)

Date: Tue Dec 01 2026 - 05:02:06 EST


On 11/28/26 00:01, Yury Norov wrote:
> Introduce 'small' and 'large' compile-time sizes for nodemask operations,
> similarly to how it works for cpumasks. Small_nodemask_bits is used by
> single nodemask operations and searches, and large_nodemask_bits is used
> by clearing and copying. The nr_node_ids is used where the exact runtime
> length is needed.
>
> Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
> ---
> include/linux/nodemask.h | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
> index 607373bd83ee..37fd5ac957c0 100644
> --- a/include/linux/nodemask.h
> +++ b/include/linux/nodemask.h
> @@ -103,6 +103,22 @@ extern unsigned int nr_online_nodes;
> #define nr_online_nodes 1U
> #endif
>
> +/*
> + * Compile-time bounds for optimized nodemask operations. See comments
> + * for small_cpumask_bits and large_cpumask_bits in linux/cpumask.h for
> + * detailed description.
> + */
> +#if MAX_NUMNODES <= BITS_PER_LONG
> +#define small_nodemask_bits ((unsigned int)MAX_NUMNODES)
> +#define large_nodemask_bits ((unsigned int)MAX_NUMNODES)
> +#elif MAX_NUMNODES <= 4 * BITS_PER_LONG
> +#define small_nodemask_bits nr_node_ids
> +#define large_nodemask_bits ((unsigned int)MAX_NUMNODES)
> +#else
> +#define small_nodemask_bits nr_node_ids
> +#define large_nodemask_bits nr_node_ids
> +#endif

Yeah, it's exactly the same thing.

Reviewed-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

I guess one could turn this into some fancy marcro where one only passes the
name (nodemask vs. cpumask), the static max (MAX_NUMNODES vs. NR_CPUS) and the
variable for the actual number (nr_node_ids vs. nr_cpu_ids) to have a shared logic.

--
Cheers,

David