diff mbox series

mm/slub.c: freelist is ensured to be NULL when new_slab() fails

Message ID 20181229062512.30469-1-rocking@whu.edu.cn (mailing list archive)
State New, archived
Headers show
Series mm/slub.c: freelist is ensured to be NULL when new_slab() fails | expand

Commit Message

Peng Wang Dec. 29, 2018, 6:25 a.m. UTC
new_slab_objects() will return immediately if freelist is not NULL.

         if (freelist)
                 return freelist;

One more assignment operation could be avoided.

Signed-off-by: Peng Wang <rocking@whu.edu.cn>
---
 mm/slub.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Pekka Enberg Dec. 29, 2018, 10:02 a.m. UTC | #1
On 29/12/2018 8.25, Peng Wang wrote:
> new_slab_objects() will return immediately if freelist is not NULL.
> 
>           if (freelist)
>                   return freelist;
> 
> One more assignment operation could be avoided.
> 
> Signed-off-by: Peng Wang <rocking@whu.edu.cn>

Reviewed-by: Pekka Enberg <penberg@kernel.org>

> ---
>   mm/slub.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 36c0befeebd8..cf2ef4ababff 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2463,8 +2463,7 @@ static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
>   		stat(s, ALLOC_SLAB);
>   		c->page = page;
>   		*pc = c;
> -	} else
> -		freelist = NULL;
> +	}
>   
>   	return freelist;
>   }
>
David Rientjes Jan. 2, 2019, 9:43 p.m. UTC | #2
On Sat, 29 Dec 2018, Peng Wang wrote:

> new_slab_objects() will return immediately if freelist is not NULL.
> 
>          if (freelist)
>                  return freelist;
> 
> One more assignment operation could be avoided.
> 
> Signed-off-by: Peng Wang <rocking@whu.edu.cn>

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

Patch

diff --git a/mm/slub.c b/mm/slub.c
index 36c0befeebd8..cf2ef4ababff 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2463,8 +2463,7 @@  static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
 		stat(s, ALLOC_SLAB);
 		c->page = page;
 		*pc = c;
-	} else
-		freelist = NULL;
+	}
 
 	return freelist;
 }