diff mbox series

[v2,2/3] mm: vmalloc: Switch to find_unlink_vmap_area() in vm_unmap_ram()

Message ID 20221221174454.1085130-2-urezki@gmail.com (mailing list archive)
State New
Headers show
Series [v2,1/3] mm: vmalloc: Avoid of calling __find_vmap_area() twise in __vunmap() | expand

Commit Message

Uladzislau Rezki Dec. 21, 2022, 5:44 p.m. UTC
Switch from find_vmap_area() to find_unlink_vmap_area() to prevent
a double access to the vmap_area_lock: one for finding area, second
time is for unlinking from a tree.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 mm/vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Hellwig Dec. 22, 2022, 8:50 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

On Wed, Dec 21, 2022 at 06:44:53PM +0100, Uladzislau Rezki (Sony) wrote:
> Switch from find_vmap_area() to find_unlink_vmap_area() to prevent
> a double access to the vmap_area_lock: one for finding area, second
> time is for unlinking from a tree.
> 
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
>  mm/vmalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 28030d2441f1..17e688cc7357 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2251,7 +2251,7 @@ void vm_unmap_ram(const void *mem, unsigned int count)
>  		return;
>  	}
>  
> -	va = find_vmap_area(addr);
> +	va = find_unlink_vmap_area(addr);

I can't find find_unlink_vmap_area in current -next, but shouldn't
this also switch from free_vmap_area_noflush to something that
doesn't unlink from the list and avoid the lock?

In general the code could probably use a bit of refactoring to
split unmapping from freeing.
diff mbox series

Patch

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 28030d2441f1..17e688cc7357 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2251,7 +2251,7 @@  void vm_unmap_ram(const void *mem, unsigned int count)
 		return;
 	}
 
-	va = find_vmap_area(addr);
+	va = find_unlink_vmap_area(addr);
 	BUG_ON(!va);
 	debug_check_no_locks_freed((void *)va->va_start,
 				    (va->va_end - va->va_start));