Re: [PATCH] mm, slab: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO.

Vlastimil Babka
2020-06-17T10:43:54Z

On 6/17/20 9:15 AM, Yi Wang wrote:
> From: Liao Pingfang <liao.pingfang@zte.com.cn>
>
> Use kmem_cache_zalloc instead of manually calling kmem_cache_alloc
> with flag GFP_ZERO.
>
> Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn>
> ---
> include/linux/slab.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 6d45488..1fa62d9 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -656,7 +656,7 @@ extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
> */
> static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
> {
> - return kmem_cache_alloc(k, flags | __GFP_ZERO);
> + return kmem_cache_zalloc(k, flags);

Did you test this patch?

> }
>
> /**
>