All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/slub: remove unneeded return value of slab_pad_check
@ 2022-04-19 12:03 Miaohe Lin
  2022-04-20 11:47 ` Hyeonggon Yoo
  2022-04-20 17:46 ` Vlastimil Babka
  0 siblings, 2 replies; 3+ messages in thread
From: Miaohe Lin @ 2022-04-19 12:03 UTC (permalink / raw)
  To: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka
  Cc: roman.gushchin, linux-mm, linux-kernel, linmiaohe

The return value of slab_pad_check is never used. So we can make it return
void now.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/slub.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 6dc703488d30..1f699ddfff7f 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1017,7 +1017,7 @@ static int check_pad_bytes(struct kmem_cache *s, struct slab *slab, u8 *p)
 }
 
 /* Check the pad bytes at the end of a slab page */
-static int slab_pad_check(struct kmem_cache *s, struct slab *slab)
+static void slab_pad_check(struct kmem_cache *s, struct slab *slab)
 {
 	u8 *start;
 	u8 *fault;
@@ -1027,21 +1027,21 @@ static int slab_pad_check(struct kmem_cache *s, struct slab *slab)
 	int remainder;
 
 	if (!(s->flags & SLAB_POISON))
-		return 1;
+		return;
 
 	start = slab_address(slab);
 	length = slab_size(slab);
 	end = start + length;
 	remainder = length % s->size;
 	if (!remainder)
-		return 1;
+		return;
 
 	pad = end - remainder;
 	metadata_access_enable();
 	fault = memchr_inv(kasan_reset_tag(pad), POISON_INUSE, remainder);
 	metadata_access_disable();
 	if (!fault)
-		return 1;
+		return;
 	while (end > fault && end[-1] == POISON_INUSE)
 		end--;
 
@@ -1050,7 +1050,6 @@ static int slab_pad_check(struct kmem_cache *s, struct slab *slab)
 	print_section(KERN_ERR, "Padding ", pad, remainder);
 
 	restore_bytes(s, "slab padding", POISON_INUSE, fault, end);
-	return 0;
 }
 
 static int check_object(struct kmem_cache *s, struct slab *slab,
@@ -1642,8 +1641,7 @@ static inline int free_debug_processing(
 	void *head, void *tail, int bulk_cnt,
 	unsigned long addr) { return 0; }
 
-static inline int slab_pad_check(struct kmem_cache *s, struct slab *slab)
-			{ return 1; }
+static inline void slab_pad_check(struct kmem_cache *s, struct slab *slab) {}
 static inline int check_object(struct kmem_cache *s, struct slab *slab,
 			void *object, u8 val) { return 1; }
 static inline void add_full(struct kmem_cache *s, struct kmem_cache_node *n,
-- 
2.23.0


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

* Re: [PATCH] mm/slub: remove unneeded return value of slab_pad_check
  2022-04-19 12:03 [PATCH] mm/slub: remove unneeded return value of slab_pad_check Miaohe Lin
@ 2022-04-20 11:47 ` Hyeonggon Yoo
  2022-04-20 17:46 ` Vlastimil Babka
  1 sibling, 0 replies; 3+ messages in thread
From: Hyeonggon Yoo @ 2022-04-20 11:47 UTC (permalink / raw)
  To: Miaohe Lin
  Cc: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka,
	roman.gushchin, linux-mm, linux-kernel

On Tue, Apr 19, 2022 at 08:03:52PM +0800, Miaohe Lin wrote:
> The return value of slab_pad_check is never used. So we can make it return
> void now.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/slub.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 6dc703488d30..1f699ddfff7f 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1017,7 +1017,7 @@ static int check_pad_bytes(struct kmem_cache *s, struct slab *slab, u8 *p)
>  }
>  
>  /* Check the pad bytes at the end of a slab page */
> -static int slab_pad_check(struct kmem_cache *s, struct slab *slab)
> +static void slab_pad_check(struct kmem_cache *s, struct slab *slab)
>  {
>  	u8 *start;
>  	u8 *fault;
> @@ -1027,21 +1027,21 @@ static int slab_pad_check(struct kmem_cache *s, struct slab *slab)
>  	int remainder;
>  
>  	if (!(s->flags & SLAB_POISON))
> -		return 1;
> +		return;
>  
>  	start = slab_address(slab);
>  	length = slab_size(slab);
>  	end = start + length;
>  	remainder = length % s->size;
>  	if (!remainder)
> -		return 1;
> +		return;
>  
>  	pad = end - remainder;
>  	metadata_access_enable();
>  	fault = memchr_inv(kasan_reset_tag(pad), POISON_INUSE, remainder);
>  	metadata_access_disable();
>  	if (!fault)
> -		return 1;
> +		return;
>  	while (end > fault && end[-1] == POISON_INUSE)
>  		end--;
>  
> @@ -1050,7 +1050,6 @@ static int slab_pad_check(struct kmem_cache *s, struct slab *slab)
>  	print_section(KERN_ERR, "Padding ", pad, remainder);
>  
>  	restore_bytes(s, "slab padding", POISON_INUSE, fault, end);
> -	return 0;
>  }
>  
>  static int check_object(struct kmem_cache *s, struct slab *slab,
> @@ -1642,8 +1641,7 @@ static inline int free_debug_processing(
>  	void *head, void *tail, int bulk_cnt,
>  	unsigned long addr) { return 0; }
>  
> -static inline int slab_pad_check(struct kmem_cache *s, struct slab *slab)
> -			{ return 1; }
> +static inline void slab_pad_check(struct kmem_cache *s, struct slab *slab) {}
>  static inline int check_object(struct kmem_cache *s, struct slab *slab,
>  			void *object, u8 val) { return 1; }
>  static inline void add_full(struct kmem_cache *s, struct kmem_cache_node *n,

Seems the return value was not used even at birth of SLUB.

Looks good to me.

Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>

Thanks!

> -- 
> 2.23.0
> 
> 

-- 
Thanks,
Hyeonggon

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

* Re: [PATCH] mm/slub: remove unneeded return value of slab_pad_check
  2022-04-19 12:03 [PATCH] mm/slub: remove unneeded return value of slab_pad_check Miaohe Lin
  2022-04-20 11:47 ` Hyeonggon Yoo
@ 2022-04-20 17:46 ` Vlastimil Babka
  1 sibling, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2022-04-20 17:46 UTC (permalink / raw)
  To: Miaohe Lin, cl, penberg, rientjes, iamjoonsoo.kim, akpm
  Cc: roman.gushchin, linux-mm, linux-kernel

On 4/19/22 14:03, Miaohe Lin wrote:
> The return value of slab_pad_check is never used. So we can make it return
> void now.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Added, thanks.

> ---
>  mm/slub.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 6dc703488d30..1f699ddfff7f 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1017,7 +1017,7 @@ static int check_pad_bytes(struct kmem_cache *s, struct slab *slab, u8 *p)
>  }
>  
>  /* Check the pad bytes at the end of a slab page */
> -static int slab_pad_check(struct kmem_cache *s, struct slab *slab)
> +static void slab_pad_check(struct kmem_cache *s, struct slab *slab)
>  {
>  	u8 *start;
>  	u8 *fault;
> @@ -1027,21 +1027,21 @@ static int slab_pad_check(struct kmem_cache *s, struct slab *slab)
>  	int remainder;
>  
>  	if (!(s->flags & SLAB_POISON))
> -		return 1;
> +		return;
>  
>  	start = slab_address(slab);
>  	length = slab_size(slab);
>  	end = start + length;
>  	remainder = length % s->size;
>  	if (!remainder)
> -		return 1;
> +		return;
>  
>  	pad = end - remainder;
>  	metadata_access_enable();
>  	fault = memchr_inv(kasan_reset_tag(pad), POISON_INUSE, remainder);
>  	metadata_access_disable();
>  	if (!fault)
> -		return 1;
> +		return;
>  	while (end > fault && end[-1] == POISON_INUSE)
>  		end--;
>  
> @@ -1050,7 +1050,6 @@ static int slab_pad_check(struct kmem_cache *s, struct slab *slab)
>  	print_section(KERN_ERR, "Padding ", pad, remainder);
>  
>  	restore_bytes(s, "slab padding", POISON_INUSE, fault, end);
> -	return 0;
>  }
>  
>  static int check_object(struct kmem_cache *s, struct slab *slab,
> @@ -1642,8 +1641,7 @@ static inline int free_debug_processing(
>  	void *head, void *tail, int bulk_cnt,
>  	unsigned long addr) { return 0; }
>  
> -static inline int slab_pad_check(struct kmem_cache *s, struct slab *slab)
> -			{ return 1; }
> +static inline void slab_pad_check(struct kmem_cache *s, struct slab *slab) {}
>  static inline int check_object(struct kmem_cache *s, struct slab *slab,
>  			void *object, u8 val) { return 1; }
>  static inline void add_full(struct kmem_cache *s, struct kmem_cache_node *n,


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

end of thread, other threads:[~2022-04-20 17:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 12:03 [PATCH] mm/slub: remove unneeded return value of slab_pad_check Miaohe Lin
2022-04-20 11:47 ` Hyeonggon Yoo
2022-04-20 17:46 ` Vlastimil Babka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.