Skip to content

Commit aed760d

Browse files
ptesariktehcaster
authored andcommitted
slab: convert setup_slub_debug() to use __core_param_cb()
Use __core_param_cb() to parse the "slab_debug" kernel parameter instead of the obsolescent __setup(). For now, the parameter is not exposed in sysfs, and no get ops is provided. There is a slight change in behavior. Before this patch, the following parameter would silently turn on full debugging for all slabs: slub_debug_yada_yada_gotta_love_this=hail_satan! This syntax is now rejected, and the parameter will be passed to user space, making the kernel a holier place. Signed-off-by: Petr Tesarik <ptesarik@suse.com> Link: https://patch.msgid.link/9674b34861394088c7853edf8e9d2b439fd4b42f.1761324765.git.ptesarik@suse.com Reviewed-by: Harry Yoo <harry.yoo@oracle.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent d3722ff commit aed760d

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

mm/slub.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,18 +1863,17 @@ parse_slub_debug_flags(const char *str, slab_flags_t *flags, const char **slabs,
18631863
return NULL;
18641864
}
18651865

1866-
static int __init setup_slub_debug(char *val)
1866+
static int __init setup_slub_debug(const char *str, const struct kernel_param *kp)
18671867
{
18681868
slab_flags_t flags;
18691869
slab_flags_t global_flags;
18701870
const char *saved_str;
18711871
const char *slab_list;
18721872
bool global_slub_debug_changed = false;
18731873
bool slab_list_specified = false;
1874-
const char *str = val;
18751874

18761875
global_flags = DEBUG_DEFAULT_FLAGS;
1877-
if (*str++ != '=' || !*str)
1876+
if (!str || !*str)
18781877
/*
18791878
* No options specified. Switch on full debugging.
18801879
*/
@@ -1918,11 +1917,15 @@ static int __init setup_slub_debug(char *val)
19181917
static_branch_unlikely(&init_on_free)) &&
19191918
(slub_debug & SLAB_POISON))
19201919
pr_info("mem auto-init: SLAB_POISON will take precedence over init_on_alloc/init_on_free\n");
1921-
return 1;
1920+
return 0;
19221921
}
19231922

1924-
__setup("slab_debug", setup_slub_debug);
1925-
__setup_param("slub_debug", slub_debug, setup_slub_debug, 0);
1923+
static const struct kernel_param_ops param_ops_slab_debug __initconst = {
1924+
.flags = KERNEL_PARAM_OPS_FL_NOARG,
1925+
.set = setup_slub_debug,
1926+
};
1927+
__core_param_cb(slab_debug, &param_ops_slab_debug, NULL, 0);
1928+
__core_param_cb(slub_debug, &param_ops_slab_debug, NULL, 0);
19261929

19271930
/*
19281931
* kmem_cache_flags - apply debugging options to the cache

0 commit comments

Comments
 (0)