Re: [PATCH v4] mm/execmem: Make the populate and alloc atomic

From: Mike Rapoport

Date: Sun Mar 22 2026 - 07:01:49 EST


On Fri, Mar 20, 2026 at 07:57:23AM +0000, Hubert Mazur wrote:
> When a block of memory is requested from the execmem manager it tries
> to find a suitable fragment by traversing the free_areas. In case
> there is no such block, a new memory area is added to the free_areas
> and then allocated to the caller by traversing the free_area tree again.
>
> The above operations of allocation and tree traversal are not atomic
> hence another request may consume this newly allocated memory block
> which results in the allocation failure for the original request.
> Such occurrence can be spotted on devices running the 6.18 kernel
> during the parallel modules loading.
>
> To mitigate such resource races execute the cache population and
> allocation operations under one mutex lock.
>
> Signed-off-by: Hubert Mazur <hmazur@xxxxxxxxxx>

Reviewed-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>

> ---

--
Sincerely yours,
Mike.