diff mbox series

[v2,05/15] slab: port kmem_cache_create_usercopy() to struct kmem_cache_args

Message ID 20240903-work-kmem_cache_args-v2-5-76f97e9a4560@kernel.org (mailing list archive)
State New
Headers show
Series slab: add struct kmem_cache_args | expand

Commit Message

Christian Brauner Sept. 3, 2024, 2:20 p.m. UTC
Pprt kmem_cache_create_usercopy() to struct kmem_cache_args and remove
the now unused do_kmem_cache_create_usercopy() helper.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 mm/slab_common.c | 30 ++++++++----------------------
 1 file changed, 8 insertions(+), 22 deletions(-)

Comments

Mike Rapoport Sept. 4, 2024, 4:56 a.m. UTC | #1
On Tue, Sep 03, 2024 at 04:20:46PM +0200, Christian Brauner wrote:
> Pprt kmem_cache_create_usercopy() to struct kmem_cache_args and remove
> the now unused do_kmem_cache_create_usercopy() helper.
> 
> Signed-off-by: Christian Brauner <brauner@kernel.org>

Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

> ---
>  mm/slab_common.c | 30 ++++++++----------------------
>  1 file changed, 8 insertions(+), 22 deletions(-)
> 
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index da62ed30f95d..16c36a946135 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -351,26 +351,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name,
>  }
>  EXPORT_SYMBOL(__kmem_cache_create_args);
>  
> -static struct kmem_cache *
> -do_kmem_cache_create_usercopy(const char *name,
> -                 unsigned int size, unsigned int freeptr_offset,
> -                 unsigned int align, slab_flags_t flags,
> -                 unsigned int useroffset, unsigned int usersize,
> -                 void (*ctor)(void *))
> -{
> -	struct kmem_cache_args kmem_args = {
> -		.align			= align,
> -		.use_freeptr_offset	= freeptr_offset != UINT_MAX,
> -		.freeptr_offset		= freeptr_offset,
> -		.useroffset		= useroffset,
> -		.usersize		= usersize,
> -		.ctor			= ctor,
> -	};
> -
> -	return __kmem_cache_create_args(name, size, &kmem_args, flags);
> -}
> -
> -
>  /**
>   * kmem_cache_create_usercopy - Create a cache with a region suitable
>   * for copying to userspace
> @@ -405,8 +385,14 @@ kmem_cache_create_usercopy(const char *name, unsigned int size,
>  			   unsigned int useroffset, unsigned int usersize,
>  			   void (*ctor)(void *))
>  {
> -	return do_kmem_cache_create_usercopy(name, size, UINT_MAX, align, flags,
> -					     useroffset, usersize, ctor);
> +	struct kmem_cache_args kmem_args = {
> +		.align		= align,
> +		.ctor		= ctor,
> +		.useroffset	= useroffset,
> +		.usersize	= usersize,
> +	};
> +
> +	return __kmem_cache_create_args(name, size, &kmem_args, flags);
>  }
>  EXPORT_SYMBOL(kmem_cache_create_usercopy);
>  
> 
> -- 
> 2.45.2
>
Vlastimil Babka Sept. 4, 2024, 8:14 a.m. UTC | #2
On 9/3/24 16:20, Christian Brauner wrote:
> Pprt kmem_cache_create_usercopy() to struct kmem_cache_args and remove

Typo

> the now unused do_kmem_cache_create_usercopy() helper.
> 
> Signed-off-by: Christian Brauner <brauner@kernel.org>
> ---
>  mm/slab_common.c | 30 ++++++++----------------------
>  1 file changed, 8 insertions(+), 22 deletions(-)
> 
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index da62ed30f95d..16c36a946135 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -351,26 +351,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name,
>  }
>  EXPORT_SYMBOL(__kmem_cache_create_args);
>  
> -static struct kmem_cache *
> -do_kmem_cache_create_usercopy(const char *name,
> -                 unsigned int size, unsigned int freeptr_offset,
> -                 unsigned int align, slab_flags_t flags,
> -                 unsigned int useroffset, unsigned int usersize,
> -                 void (*ctor)(void *))
> -{
> -	struct kmem_cache_args kmem_args = {
> -		.align			= align,
> -		.use_freeptr_offset	= freeptr_offset != UINT_MAX,
> -		.freeptr_offset		= freeptr_offset,
> -		.useroffset		= useroffset,
> -		.usersize		= usersize,
> -		.ctor			= ctor,
> -	};
> -
> -	return __kmem_cache_create_args(name, size, &kmem_args, flags);
> -}
> -
> -
>  /**
>   * kmem_cache_create_usercopy - Create a cache with a region suitable
>   * for copying to userspace
> @@ -405,8 +385,14 @@ kmem_cache_create_usercopy(const char *name, unsigned int size,
>  			   unsigned int useroffset, unsigned int usersize,
>  			   void (*ctor)(void *))
>  {
> -	return do_kmem_cache_create_usercopy(name, size, UINT_MAX, align, flags,
> -					     useroffset, usersize, ctor);
> +	struct kmem_cache_args kmem_args = {
> +		.align		= align,
> +		.ctor		= ctor,
> +		.useroffset	= useroffset,
> +		.usersize	= usersize,
> +	};
> +
> +	return __kmem_cache_create_args(name, size, &kmem_args, flags);
>  }
>  EXPORT_SYMBOL(kmem_cache_create_usercopy);
>  
>
Christian Brauner Sept. 4, 2024, 8:59 a.m. UTC | #3
On Wed, Sep 04, 2024 at 10:14:37AM GMT, Vlastimil Babka wrote:
> On 9/3/24 16:20, Christian Brauner wrote:
> > Pprt kmem_cache_create_usercopy() to struct kmem_cache_args and remove
> 
> Typo

Fixed on the work.kmem_cache_args branch.
diff mbox series

Patch

diff --git a/mm/slab_common.c b/mm/slab_common.c
index da62ed30f95d..16c36a946135 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -351,26 +351,6 @@  struct kmem_cache *__kmem_cache_create_args(const char *name,
 }
 EXPORT_SYMBOL(__kmem_cache_create_args);
 
-static struct kmem_cache *
-do_kmem_cache_create_usercopy(const char *name,
-                 unsigned int size, unsigned int freeptr_offset,
-                 unsigned int align, slab_flags_t flags,
-                 unsigned int useroffset, unsigned int usersize,
-                 void (*ctor)(void *))
-{
-	struct kmem_cache_args kmem_args = {
-		.align			= align,
-		.use_freeptr_offset	= freeptr_offset != UINT_MAX,
-		.freeptr_offset		= freeptr_offset,
-		.useroffset		= useroffset,
-		.usersize		= usersize,
-		.ctor			= ctor,
-	};
-
-	return __kmem_cache_create_args(name, size, &kmem_args, flags);
-}
-
-
 /**
  * kmem_cache_create_usercopy - Create a cache with a region suitable
  * for copying to userspace
@@ -405,8 +385,14 @@  kmem_cache_create_usercopy(const char *name, unsigned int size,
 			   unsigned int useroffset, unsigned int usersize,
 			   void (*ctor)(void *))
 {
-	return do_kmem_cache_create_usercopy(name, size, UINT_MAX, align, flags,
-					     useroffset, usersize, ctor);
+	struct kmem_cache_args kmem_args = {
+		.align		= align,
+		.ctor		= ctor,
+		.useroffset	= useroffset,
+		.usersize	= usersize,
+	};
+
+	return __kmem_cache_create_args(name, size, &kmem_args, flags);
 }
 EXPORT_SYMBOL(kmem_cache_create_usercopy);