Skip to content

Commit 66b3dc1

Browse files
Zheng Yejiantehcaster
authored andcommitted
mm/slub: remove parameter 'flags' in create_kmalloc_caches()
After commit 16a1d96 ("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> Acked-by: David Rientjes <rientjes@google.com> Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent 98d3b6d commit 66b3dc1

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

mm/slab.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ extern const struct kmalloc_info_struct {
387387

388388
/* Kmalloc array related functions */
389389
void setup_kmalloc_cache_index_table(void);
390-
void create_kmalloc_caches(slab_flags_t);
390+
void create_kmalloc_caches(void);
391391

392392
extern u8 kmalloc_size_index[24];
393393

@@ -422,8 +422,6 @@ gfp_t kmalloc_fix_flags(gfp_t flags);
422422
int __kmem_cache_create(struct kmem_cache *, slab_flags_t flags);
423423

424424
void __init kmem_cache_init(void);
425-
void __init new_kmalloc_cache(int idx, enum kmalloc_cache_type type,
426-
slab_flags_t flags);
427425
extern void create_boot_cache(struct kmem_cache *, const char *name,
428426
unsigned int size, slab_flags_t flags,
429427
unsigned int useroffset, unsigned int usersize);

mm/slab_common.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -853,9 +853,10 @@ static unsigned int __kmalloc_minalign(void)
853853
return max(minalign, arch_slab_minalign());
854854
}
855855

856-
void __init
857-
new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags)
856+
static void __init
857+
new_kmalloc_cache(int idx, enum kmalloc_cache_type type)
858858
{
859+
slab_flags_t flags = 0;
859860
unsigned int minalign = __kmalloc_minalign();
860861
unsigned int aligned_size = kmalloc_info[idx].size;
861862
int aligned_idx = idx;
@@ -902,7 +903,7 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags)
902903
* may already have been created because they were needed to
903904
* enable allocations for slab creation.
904905
*/
905-
void __init create_kmalloc_caches(slab_flags_t flags)
906+
void __init create_kmalloc_caches(void)
906907
{
907908
int i;
908909
enum kmalloc_cache_type type;
@@ -913,7 +914,7 @@ void __init create_kmalloc_caches(slab_flags_t flags)
913914
for (type = KMALLOC_NORMAL; type < NR_KMALLOC_TYPES; type++) {
914915
for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
915916
if (!kmalloc_caches[type][i])
916-
new_kmalloc_cache(i, type, flags);
917+
new_kmalloc_cache(i, type);
917918

918919
/*
919920
* 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)
922923
*/
923924
if (KMALLOC_MIN_SIZE <= 32 && i == 6 &&
924925
!kmalloc_caches[type][1])
925-
new_kmalloc_cache(1, type, flags);
926+
new_kmalloc_cache(1, type);
926927
if (KMALLOC_MIN_SIZE <= 64 && i == 7 &&
927928
!kmalloc_caches[type][2])
928-
new_kmalloc_cache(2, type, flags);
929+
new_kmalloc_cache(2, type);
929930
}
930931
}
931932
#ifdef CONFIG_RANDOM_KMALLOC_CACHES

mm/slub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5668,7 +5668,7 @@ void __init kmem_cache_init(void)
56685668

56695669
/* Now we can use the kmem_cache to allocate kmalloc slabs */
56705670
setup_kmalloc_cache_index_table();
5671-
create_kmalloc_caches(0);
5671+
create_kmalloc_caches();
56725672

56735673
/* Setup random freelists for each cache */
56745674
init_freelist_randomization();

0 commit comments

Comments
 (0)