Re: [PATCH v1] mm: Consistently use current->mm in mm_get_unmapped_area()

From: David Hildenbrand

Date: Mon Oct 06 2025 - 04:20:09 EST


On 03.10.25 17:53, Ryan Roberts wrote:
mm_get_unmapped_area() is a wrapper around arch_get_unmapped_area() /
arch_get_unmapped_area_topdown(), both of which search current->mm for
some free space. Neither take an mm_struct - they implicitly operate on
current->mm.

But the wrapper takes an mm_struct and uses it to decide whether to
search bottom up or top down. All callers pass in current->mm for this,
so everything is working consistently. But it feels like an accident
waiting to happen; eventually someone will call that function with a
different mm, expecting to find free space in it, but what gets returned
is free space in the current mm.

So let's simplify by removing the parameter and have the wrapper use
current->mm to decide which end to start at. Now everything is
consistent and self-documenting.

Signed-off-by: Ryan Roberts <ryan.roberts@xxxxxxx>

Yeah, that looks better to me.

Acked-by: David Hildenbrand <david@xxxxxxxxxx>

--
Cheers

David / dhildenb