linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chengming Zhou <zhouchengming@bytedance.com>
To: Zheng Yejian <zhengyejian1@huawei.com>,
	cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
	vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/slub: remove parameter 'flags' in create_kmalloc_caches()
Date: Tue, 30 Jan 2024 11:50:36 +0800	[thread overview]
Message-ID: <4881a71a-2d40-44b7-ad13-0cf7ab62b463@bytedance.com> (raw)
In-Reply-To: <20240130014107.1262373-1-zhengyejian1@huawei.com>

On 2024/1/30 09:41, Zheng Yejian wrote:
> After commit 16a1d968358a ("mm/slab: remove mm/slab.c and slab_def.h"),
> parameter 'flags' is only passed as 0 in create_kmalloc_caches(), and
> then it is only passed to new_kmalloc_cache().
> 
> So we can change parameter 'flags' to be a local variable with
> initial value 0 in new_kmalloc_cache() and remove parameter 'flags'
> in create_kmalloc_caches(). Also make new_kmalloc_cache() static
> due to it is only used in mm/slab_common.c.
> 
> Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>

Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com>

Thanks.

> ---
>  mm/slab.h        |  4 +---
>  mm/slab_common.c | 13 +++++++------
>  mm/slub.c        |  2 +-
>  3 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/slab.h b/mm/slab.h
> index 54deeb0428c6..09c673346ece 100644
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -387,7 +387,7 @@ extern const struct kmalloc_info_struct {
>  
>  /* Kmalloc array related functions */
>  void setup_kmalloc_cache_index_table(void);
> -void create_kmalloc_caches(slab_flags_t);
> +void create_kmalloc_caches(void);
>  
>  extern u8 kmalloc_size_index[24];
>  
> @@ -422,8 +422,6 @@ gfp_t kmalloc_fix_flags(gfp_t flags);
>  int __kmem_cache_create(struct kmem_cache *, slab_flags_t flags);
>  
>  void __init kmem_cache_init(void);
> -void __init new_kmalloc_cache(int idx, enum kmalloc_cache_type type,
> -			      slab_flags_t flags);
>  extern void create_boot_cache(struct kmem_cache *, const char *name,
>  			unsigned int size, slab_flags_t flags,
>  			unsigned int useroffset, unsigned int usersize);
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 238293b1dbe1..61530df8b35b 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -853,9 +853,10 @@ static unsigned int __kmalloc_minalign(void)
>  	return max(minalign, arch_slab_minalign());
>  }
>  
> -void __init
> -new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags)
> +static void __init
> +new_kmalloc_cache(int idx, enum kmalloc_cache_type type)
>  {
> +	slab_flags_t flags = 0;
>  	unsigned int minalign = __kmalloc_minalign();
>  	unsigned int aligned_size = kmalloc_info[idx].size;
>  	int aligned_idx = idx;
> @@ -902,7 +903,7 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags)
>   * may already have been created because they were needed to
>   * enable allocations for slab creation.
>   */
> -void __init create_kmalloc_caches(slab_flags_t flags)
> +void __init create_kmalloc_caches(void)
>  {
>  	int i;
>  	enum kmalloc_cache_type type;
> @@ -913,7 +914,7 @@ void __init create_kmalloc_caches(slab_flags_t flags)
>  	for (type = KMALLOC_NORMAL; type < NR_KMALLOC_TYPES; type++) {
>  		for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
>  			if (!kmalloc_caches[type][i])
> -				new_kmalloc_cache(i, type, flags);
> +				new_kmalloc_cache(i, type);
>  
>  			/*
>  			 * Caches that are not of the two-to-the-power-of size.
> @@ -922,10 +923,10 @@ void __init create_kmalloc_caches(slab_flags_t flags)
>  			 */
>  			if (KMALLOC_MIN_SIZE <= 32 && i == 6 &&
>  					!kmalloc_caches[type][1])
> -				new_kmalloc_cache(1, type, flags);
> +				new_kmalloc_cache(1, type);
>  			if (KMALLOC_MIN_SIZE <= 64 && i == 7 &&
>  					!kmalloc_caches[type][2])
> -				new_kmalloc_cache(2, type, flags);
> +				new_kmalloc_cache(2, type);
>  		}
>  	}
>  #ifdef CONFIG_RANDOM_KMALLOC_CACHES
> diff --git a/mm/slub.c b/mm/slub.c
> index 2ef88bbf56a3..4f912f5ec11c 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -5663,7 +5663,7 @@ void __init kmem_cache_init(void)
>  
>  	/* Now we can use the kmem_cache to allocate kmalloc slabs */
>  	setup_kmalloc_cache_index_table();
> -	create_kmalloc_caches(0);
> +	create_kmalloc_caches();
>  
>  	/* Setup random freelists for each cache */
>  	init_freelist_randomization();



  parent reply	other threads:[~2024-01-30  3:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30  1:41 Zheng Yejian
2024-01-30  3:11 ` David Rientjes
2024-01-30  3:50 ` Chengming Zhou [this message]
2024-01-30 13:16 ` Vlastimil Babka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4881a71a-2d40-44b7-ad13-0cf7ab62b463@bytedance.com \
    --to=zhouchengming@bytedance.com \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@suse.cz \
    --cc=zhengyejian1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox