diff mbox series

[02/10] mm: remove __vfree

Message ID 20230119100226.789506-3-hch@lst.de (mailing list archive)
State New
Headers show
Series [01/10] vmalloc: reject vmap with VM_FLUSH_RESET_PERMS | expand

Commit Message

hch@lst.de Jan. 19, 2023, 10:02 a.m. UTC
__vfree is a subset of vfree that just skips a few checks, and which is
only used by vfree and an error cleanup path.  Fold __vfree into vfree
and switch the only other caller to call vfree() instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 mm/vmalloc.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

Comments

Uladzislau Rezki Jan. 19, 2023, 6:47 p.m. UTC | #1
On Thu, Jan 19, 2023 at 11:02:18AM +0100, Christoph Hellwig wrote:
> __vfree is a subset of vfree that just skips a few checks, and which is
> only used by vfree and an error cleanup path.  Fold __vfree into vfree
> and switch the only other caller to call vfree() instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  mm/vmalloc.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 6957d15d526e46..b989828b45109a 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2801,14 +2801,6 @@ void vfree_atomic(const void *addr)
>  	__vfree_deferred(addr);
>  }
>  
> -static void __vfree(const void *addr)
> -{
> -	if (unlikely(in_interrupt()))
> -		__vfree_deferred(addr);
> -	else
> -		__vunmap(addr, 1);
> -}
> -
>  /**
>   * vfree - Release memory allocated by vmalloc()
>   * @addr:  Memory base address
> @@ -2836,8 +2828,10 @@ void vfree(const void *addr)
>  
>  	if (!addr)
>  		return;
> -
> -	__vfree(addr);
> +	if (unlikely(in_interrupt()))
> +		__vfree_deferred(addr);
> +	else
> +		__vunmap(addr, 1);
>  }
>  EXPORT_SYMBOL(vfree);
>  
> @@ -3104,7 +3098,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
>  
>  	/*
>  	 * If not enough pages were obtained to accomplish an
> -	 * allocation request, free them via __vfree() if any.
> +	 * allocation request, free them via vfree() if any.
>  	 */
>  	if (area->nr_pages != nr_small_pages) {
>  		warn_alloc(gfp_mask, NULL,
> @@ -3144,7 +3138,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
>  	return area->addr;
>  
>  fail:
> -	__vfree(area->addr);
> +	vfree(area->addr);
>  	return NULL;
>  }
>  
> -- 
> 2.39.0
> 
Makes sense to me.

Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

--
Uladzislau Rezki
diff mbox series

Patch

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 6957d15d526e46..b989828b45109a 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2801,14 +2801,6 @@  void vfree_atomic(const void *addr)
 	__vfree_deferred(addr);
 }
 
-static void __vfree(const void *addr)
-{
-	if (unlikely(in_interrupt()))
-		__vfree_deferred(addr);
-	else
-		__vunmap(addr, 1);
-}
-
 /**
  * vfree - Release memory allocated by vmalloc()
  * @addr:  Memory base address
@@ -2836,8 +2828,10 @@  void vfree(const void *addr)
 
 	if (!addr)
 		return;
-
-	__vfree(addr);
+	if (unlikely(in_interrupt()))
+		__vfree_deferred(addr);
+	else
+		__vunmap(addr, 1);
 }
 EXPORT_SYMBOL(vfree);
 
@@ -3104,7 +3098,7 @@  static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
 
 	/*
 	 * If not enough pages were obtained to accomplish an
-	 * allocation request, free them via __vfree() if any.
+	 * allocation request, free them via vfree() if any.
 	 */
 	if (area->nr_pages != nr_small_pages) {
 		warn_alloc(gfp_mask, NULL,
@@ -3144,7 +3138,7 @@  static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
 	return area->addr;
 
 fail:
-	__vfree(area->addr);
+	vfree(area->addr);
 	return NULL;
 }