Re: [PATCH 12/13] percpu: search the whole reserved chunk
From: Gregory Price (Meta)
Date: Thu Nov 12 2026 - 13:48:58 EST
On 2026-11-11 18:13 +0000, Lorenzo Stoakes (ARM) wrote:
> Loading a module with static percpu data can fail with -ENOMEM even
> though the reserved chunk has a free area that fits the data.
>
> pcpu_find_block_fit() does not scan the allocation bitmap, rather it
> tests the request against hints, starting with the contig_hint of the
> chunk, which describes its largest free area. If that area is too small
> once aligned, the search gives up even if a smaller free area fits.
>
> Consider:
>
> request: 256 bytes, aligned to 256 bytes
> contig_hint: 260 bytes, starts 4 bytes after a 256-byte boundary,
> so 8 bytes remain after alignment
> also free: 256 bytes, starts on a 256-byte boundary
>
> Ordinarily this is fine as the allocator moves on to the next chunk or
> creates a new one, but the static percpu data of modules can only come
> from the reserved chunk.
>
> Fix this by searching the allocation bitmap of the reserved chunk
> directly rather than using hints.
>
> Reported-by: Chris Mason <mason@xxxxxxxxxx>
> Fixes: 13f966373f92 ("percpu: skip chunks if the alloc does not fit in the contig hint")
> Fixes: b4c2116cfae6 ("percpu: update pcpu_find_block_fit to use an iterator")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
Reproduced the exact issue.
Tested-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
Reviewed-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
--
~Gregory