Re: [PATCH 1/7] mm: allocate mm_cpumask dynamically based on nr_cpu_ids

From: Dave Hansen
Date: Fri Jun 22 2018 - 11:10:17 EST


On 06/20/2018 12:56 PM, Rik van Riel wrote:
> /*
> - * FIXME! The "sizeof(struct mm_struct)" currently includes the
> - * whole struct cpumask for the OFFSTACK case. We could change
> - * this to *only* allocate as much of it as required by the
> - * maximum number of CPU's we can ever have. The cpumask_allocation
> - * is at the end of the structure, exactly for that reason.
> + * The mm_cpumask is located at the end of mm_struct, and is
> + * dynamically sized based on nr_cpu_ids.
> */
> + mm_size = sizeof(struct mm_struct) + cpumask_size();
> +
> mm_cachep = kmem_cache_create_usercopy("mm_struct",
> - sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
> + mm_size, ARCH_MIN_MMSTRUCT_ALIGN,

Could you add a bit to that comment, like "dynamically sized based on
nr_cpu_ids" ... which is sized based on the number of possible CPUs.

I found myself wondering how that interacts with hotplug.

t mm_struct, saved_auxv),
> diff --git a/mm/init-mm.c b/mm/init-mm.c
> index f94d5d15ebc0..20fe222fe4c0 100644
> --- a/mm/init-mm.c
> +++ b/mm/init-mm.c
> @@ -15,6 +15,15 @@
> #define INIT_MM_CONTEXT(name)
> #endif
>
> +/*
> + * For dynamically allocated mm_structs, there is a dynamically sized cpumask
> + * at the end of the structure, the size of which depends on nr_cpu_ids. That...

Similar nit. Instead of calling out the variable alone, could we just
say what it means logically and then reference the variable?