Re: [PATCH] cpumask: Create dedicated kmem cache for cpumask var

From: Rasmus Villemoes
Date: Wed Mar 20 2024 - 05:03:14 EST


On 19/03/2024 13.24, Dawei Li wrote:
> alloc_cpumask_var_node() and friends allocate cpumask var dynamically
> for CONFIG_CPUMASK_OFFSTACK=y kernel. The allocated size of cpumask var
> is cpumask_size(), which is runtime constant after nr_cpu_ids is
> freezed.
>
> Create a dedicated kmem cache for dynamic allocation of cpumask var.

Why?

> The window for creation of cache is somewhat narrow:
> - After last update of nr_cpu_ids(via set_nr_cpu_ids())
> - After kmem cache is available.
> - Before any alloc_cpumask_var_node() invocations(sched_init() e.g).

OK, so this sounds somewhat fragile. It's maybe correct, but I fail to
see what is gained by this, and the commit message does not provide any
hints.

Rasmus