linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/slub: remove unused parameter in setup_object*()
@ 2022-04-11  7:25 JaeSang Yoo
  2022-04-11 10:29 ` Vlastimil Babka
  2022-04-12 23:35 ` David Rientjes
  0 siblings, 2 replies; 3+ messages in thread
From: JaeSang Yoo @ 2022-04-11  7:25 UTC (permalink / raw)
  To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin
  Cc: Ohhoon Kwon, Wonhyuk Yang, Jiyoup Kim, Donghyeok Kim,
	Christoph Lameter, JaeSang Yoo, linux-mm, linux-kernel

setup_object_debug() and setup_object() has unused parameter, "struct
slab *slab". Remove it.

By the commit 3ec0974210fe ("SLUB: Simplify debug code"),
setup_object_debug() were introduced to refactor previous code blocks
in the setup_object(). Previous code used SlabDebug() to init_object()
and init_tracking(). As the SlabDebug() takes "struct page *page" as
argument, the setup_object_debug() checks flag of "struct kmem_cache *s"
which doesn't require "struct page *page".
As the struct page were changed into struct slab by commit bb192ed9aa719
("mm/slub: Convert most struct page to struct slab by spatch"), but it's
still unused parameter.

Suggested-by: Ohhoon Kwon <ohkwon1043@gmail.com>
Signed-off-by: JaeSang Yoo <jsyoo5b@gmail.com>
---
 mm/slub.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 9fe000fd19ca..273bbba74ca1 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1264,8 +1264,7 @@ static inline void dec_slabs_node(struct kmem_cache *s, int node, int objects)
 }
 
 /* Object debug checks for alloc/free paths */
-static void setup_object_debug(struct kmem_cache *s, struct slab *slab,
-								void *object)
+static void setup_object_debug(struct kmem_cache *s, void *object)
 {
 	if (!kmem_cache_debug_flags(s, SLAB_STORE_USER|SLAB_RED_ZONE|__OBJECT_POISON))
 		return;
@@ -1631,8 +1630,7 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
 	return flags | slub_debug_local;
 }
 #else /* !CONFIG_SLUB_DEBUG */
-static inline void setup_object_debug(struct kmem_cache *s,
-			struct slab *slab, void *object) {}
+static inline void setup_object_debug(struct kmem_cache *s, void *object) {}
 static inline
 void setup_slab_debug(struct kmem_cache *s, struct slab *slab, void *addr) {}
 
@@ -1775,10 +1773,9 @@ static inline bool slab_free_freelist_hook(struct kmem_cache *s,
 	return *head != NULL;
 }
 
-static void *setup_object(struct kmem_cache *s, struct slab *slab,
-				void *object)
+static void *setup_object(struct kmem_cache *s, void *object)
 {
-	setup_object_debug(s, slab, object);
+	setup_object_debug(s, object);
 	object = kasan_init_slab_obj(s, object);
 	if (unlikely(s->ctor)) {
 		kasan_unpoison_object_data(s, object);
@@ -1897,13 +1894,13 @@ static bool shuffle_freelist(struct kmem_cache *s, struct slab *slab)
 	/* First entry is used as the base of the freelist */
 	cur = next_freelist_entry(s, slab, &pos, start, page_limit,
 				freelist_count);
-	cur = setup_object(s, slab, cur);
+	cur = setup_object(s, cur);
 	slab->freelist = cur;
 
 	for (idx = 1; idx < slab->objects; idx++) {
 		next = next_freelist_entry(s, slab, &pos, start, page_limit,
 			freelist_count);
-		next = setup_object(s, slab, next);
+		next = setup_object(s, next);
 		set_freepointer(s, cur, next);
 		cur = next;
 	}
@@ -1974,11 +1971,11 @@ static struct slab *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
 
 	if (!shuffle) {
 		start = fixup_red_left(s, start);
-		start = setup_object(s, slab, start);
+		start = setup_object(s, start);
 		slab->freelist = start;
 		for (idx = 0, p = start; idx < slab->objects - 1; idx++) {
 			next = p + s->size;
-			next = setup_object(s, slab, next);
+			next = setup_object(s, next);
 			set_freepointer(s, p, next);
 			p = next;
 		}
-- 
2.25.1


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

* Re: [PATCH] mm/slub: remove unused parameter in setup_object*()
  2022-04-11  7:25 [PATCH] mm/slub: remove unused parameter in setup_object*() JaeSang Yoo
@ 2022-04-11 10:29 ` Vlastimil Babka
  2022-04-12 23:35 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2022-04-11 10:29 UTC (permalink / raw)
  To: JaeSang Yoo, Christoph Lameter, Pekka Enberg, David Rientjes,
	Joonsoo Kim, Andrew Morton, Roman Gushchin
  Cc: Ohhoon Kwon, Wonhyuk Yang, Jiyoup Kim, Donghyeok Kim,
	Christoph Lameter, JaeSang Yoo, linux-mm, linux-kernel

On 4/11/22 09:25, JaeSang Yoo wrote:
> setup_object_debug() and setup_object() has unused parameter, "struct
> slab *slab". Remove it.
> 
> By the commit 3ec0974210fe ("SLUB: Simplify debug code"),
> setup_object_debug() were introduced to refactor previous code blocks
> in the setup_object(). Previous code used SlabDebug() to init_object()
> and init_tracking(). As the SlabDebug() takes "struct page *page" as
> argument, the setup_object_debug() checks flag of "struct kmem_cache *s"
> which doesn't require "struct page *page".
> As the struct page were changed into struct slab by commit bb192ed9aa719
> ("mm/slub: Convert most struct page to struct slab by spatch"), but it's
> still unused parameter.
> 
> Suggested-by: Ohhoon Kwon <ohkwon1043@gmail.com>
> Signed-off-by: JaeSang Yoo <jsyoo5b@gmail.com>

Thanks, added.

> ---
>  mm/slub.c | 19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 9fe000fd19ca..273bbba74ca1 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1264,8 +1264,7 @@ static inline void dec_slabs_node(struct kmem_cache *s, int node, int objects)
>  }
>  
>  /* Object debug checks for alloc/free paths */
> -static void setup_object_debug(struct kmem_cache *s, struct slab *slab,
> -								void *object)
> +static void setup_object_debug(struct kmem_cache *s, void *object)
>  {
>  	if (!kmem_cache_debug_flags(s, SLAB_STORE_USER|SLAB_RED_ZONE|__OBJECT_POISON))
>  		return;
> @@ -1631,8 +1630,7 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
>  	return flags | slub_debug_local;
>  }
>  #else /* !CONFIG_SLUB_DEBUG */
> -static inline void setup_object_debug(struct kmem_cache *s,
> -			struct slab *slab, void *object) {}
> +static inline void setup_object_debug(struct kmem_cache *s, void *object) {}
>  static inline
>  void setup_slab_debug(struct kmem_cache *s, struct slab *slab, void *addr) {}
>  
> @@ -1775,10 +1773,9 @@ static inline bool slab_free_freelist_hook(struct kmem_cache *s,
>  	return *head != NULL;
>  }
>  
> -static void *setup_object(struct kmem_cache *s, struct slab *slab,
> -				void *object)
> +static void *setup_object(struct kmem_cache *s, void *object)
>  {
> -	setup_object_debug(s, slab, object);
> +	setup_object_debug(s, object);
>  	object = kasan_init_slab_obj(s, object);
>  	if (unlikely(s->ctor)) {
>  		kasan_unpoison_object_data(s, object);
> @@ -1897,13 +1894,13 @@ static bool shuffle_freelist(struct kmem_cache *s, struct slab *slab)
>  	/* First entry is used as the base of the freelist */
>  	cur = next_freelist_entry(s, slab, &pos, start, page_limit,
>  				freelist_count);
> -	cur = setup_object(s, slab, cur);
> +	cur = setup_object(s, cur);
>  	slab->freelist = cur;
>  
>  	for (idx = 1; idx < slab->objects; idx++) {
>  		next = next_freelist_entry(s, slab, &pos, start, page_limit,
>  			freelist_count);
> -		next = setup_object(s, slab, next);
> +		next = setup_object(s, next);
>  		set_freepointer(s, cur, next);
>  		cur = next;
>  	}
> @@ -1974,11 +1971,11 @@ static struct slab *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
>  
>  	if (!shuffle) {
>  		start = fixup_red_left(s, start);
> -		start = setup_object(s, slab, start);
> +		start = setup_object(s, start);
>  		slab->freelist = start;
>  		for (idx = 0, p = start; idx < slab->objects - 1; idx++) {
>  			next = p + s->size;
> -			next = setup_object(s, slab, next);
> +			next = setup_object(s, next);
>  			set_freepointer(s, p, next);
>  			p = next;
>  		}


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

* Re: [PATCH] mm/slub: remove unused parameter in setup_object*()
  2022-04-11  7:25 [PATCH] mm/slub: remove unused parameter in setup_object*() JaeSang Yoo
  2022-04-11 10:29 ` Vlastimil Babka
@ 2022-04-12 23:35 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2022-04-12 23:35 UTC (permalink / raw)
  To: JaeSang Yoo
  Cc: Christoph Lameter, Pekka Enberg, Joonsoo Kim, Andrew Morton,
	Vlastimil Babka, Roman Gushchin, Ohhoon Kwon, Wonhyuk Yang,
	Jiyoup Kim, Donghyeok Kim, Christoph Lameter, JaeSang Yoo,
	linux-mm, linux-kernel

On Mon, 11 Apr 2022, JaeSang Yoo wrote:

> setup_object_debug() and setup_object() has unused parameter, "struct
> slab *slab". Remove it.
> 
> By the commit 3ec0974210fe ("SLUB: Simplify debug code"),
> setup_object_debug() were introduced to refactor previous code blocks
> in the setup_object(). Previous code used SlabDebug() to init_object()
> and init_tracking(). As the SlabDebug() takes "struct page *page" as
> argument, the setup_object_debug() checks flag of "struct kmem_cache *s"
> which doesn't require "struct page *page".
> As the struct page were changed into struct slab by commit bb192ed9aa719
> ("mm/slub: Convert most struct page to struct slab by spatch"), but it's
> still unused parameter.
> 
> Suggested-by: Ohhoon Kwon <ohkwon1043@gmail.com>
> Signed-off-by: JaeSang Yoo <jsyoo5b@gmail.com>

Acked-by: David Rientjes <rientjes@google.com>

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

end of thread, other threads:[~2022-04-12 23:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11  7:25 [PATCH] mm/slub: remove unused parameter in setup_object*() JaeSang Yoo
2022-04-11 10:29 ` Vlastimil Babka
2022-04-12 23:35 ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).