Re: [PATCH v5 01/17] mm/sparse: relax struct mem_section size constraints
From: David Hildenbrand (Arm)
Date: Wed Sep 09 2026 - 05:53:03 EST
On 8/25/26 10:45, Muchun Song wrote:
> struct mem_section is currently forced to a power-of-2 size so the
> section-to-root lookup can use a mask instead of a modulo.
>
> That requirement makes future extensions harder than necessary: adding a
> small field can require configuration-dependent padding or layout checks
> just to preserve the lookup scheme. Keep the lookup correct for any
> struct mem_section size by using a plain modulo instead.
>
> Do not leave the layout entirely unconstrained, though. Keep struct
> mem_section double-word aligned so modest size changes, such as adding
> another word-sized field on 64-bit systems, still keep a compact and
> efficient layout. If future fields grow the structure beyond that sweet
> spot, the lookup remains correct; only the exact layout efficiency
> changes.
>
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
> Acked-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> ---
Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
--
Cheers,
David