Skip to contentSkip to conversation

mm/slab: remove duplicate check in create_cache()

PATCH In review Zhen Lei 2 participants 2 messages Oct 9, 2024

Subsystems (2)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH v2 1/1 mm/slab: remove duplicate check in create_cache()

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.

---
 mm/slab_common.c | 3 ---
 1 file changed, 3 deletions(-)

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

mm/slab_common.c +0 -3
index 3d26c257ed8b57c..88aa64fc8cd2742 100644
@@ -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 &&
Signature · 1 line
2.34.1
#1 lore raw
Quoted 9 lines · 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);
Quoted 3 lines

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

Added to slab/for-next, thanks.

Quoted 21 lines
---
 mm/slab_common.c | 3 ---
 1 file changed, 3 deletions(-)

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

mm/slab_common.c +0 -3
index 3d26c257ed8b57c..88aa64fc8cd2742 100644
@@ -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 &&