linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] mm/slab: remove duplicate check in create_cache()
@ 2024-10-09  3:54 Zhen Lei
  2024-10-09 10:59 ` Vlastimil Babka
  0 siblings, 1 reply; 2+ messages in thread
From: Zhen Lei @ 2024-10-09  3:54 UTC (permalink / raw)
  To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	linux-mm, linux-kernel
  Cc: Zhen Lei

The WARN_ON() check in static function create_cache() is done by its only
parent __kmem_cache_create_args() before calling it.
	if (... ||
	    WARN_ON(... ||
		    object_size - args->usersize < args->useroffset))
		args->usersize = args->useroffset = 0;
	...
	s = create_cache(cache_name, object_size, args, flags);

Therefore, the WARN_ON() check in create_cache() can be safely removed.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 mm/slab_common.c | 3 ---
 1 file changed, 3 deletions(-)

v1 --> v2:
Updates based on the latest v6.12-rc2.

diff --git a/mm/slab_common.c b/mm/slab_common.c
index 3d26c257ed8b57c..88aa64fc8cd2742 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -222,9 +222,6 @@ static struct kmem_cache *create_cache(const char *name,
 	struct kmem_cache *s;
 	int err;
 
-	if (WARN_ON(args->useroffset + args->usersize > object_size))
-		args->useroffset = args->usersize = 0;
-
 	/* If a custom freelist pointer is requested make sure it's sane. */
 	err = -EINVAL;
 	if (args->use_freeptr_offset &&
-- 
2.34.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 1/1] mm/slab: remove duplicate check in create_cache()
  2024-10-09  3:54 [PATCH v2 1/1] mm/slab: remove duplicate check in create_cache() Zhen Lei
@ 2024-10-09 10:59 ` Vlastimil Babka
  0 siblings, 0 replies; 2+ messages in thread
From: Vlastimil Babka @ 2024-10-09 10:59 UTC (permalink / raw)
  To: Zhen Lei, Christoph Lameter, Pekka Enberg, David Rientjes,
	Joonsoo Kim, Andrew Morton, Roman Gushchin, Hyeonggon Yoo,
	linux-mm, linux-kernel

On 10/9/24 05:54, Zhen Lei wrote:
> The WARN_ON() check in static function create_cache() is done by its only
> parent __kmem_cache_create_args() before calling it.
> 	if (... ||
> 	    WARN_ON(... ||
> 		    object_size - args->usersize < args->useroffset))
> 		args->usersize = args->useroffset = 0;
> 	...
> 	s = create_cache(cache_name, object_size, args, flags);
> 
> Therefore, the WARN_ON() check in create_cache() can be safely removed.
> 
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

Added to slab/for-next, thanks.

> ---
>  mm/slab_common.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> v1 --> v2:
> Updates based on the latest v6.12-rc2.
> 
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 3d26c257ed8b57c..88aa64fc8cd2742 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -222,9 +222,6 @@ static struct kmem_cache *create_cache(const char *name,
>  	struct kmem_cache *s;
>  	int err;
>  
> -	if (WARN_ON(args->useroffset + args->usersize > object_size))
> -		args->useroffset = args->usersize = 0;
> -
>  	/* If a custom freelist pointer is requested make sure it's sane. */
>  	err = -EINVAL;
>  	if (args->use_freeptr_offset &&



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-09 10:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-09  3:54 [PATCH v2 1/1] mm/slab: remove duplicate check in create_cache() Zhen Lei
2024-10-09 10:59 ` Vlastimil Babka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox