]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
slab: convert setup_slub_debug() to use __core_param_cb()
authorPetr Tesarik <ptesarik@suse.com>
Fri, 24 Oct 2025 17:06:53 +0000 (19:06 +0200)
committerVlastimil Babka <vbabka@suse.cz>
Mon, 27 Oct 2025 14:11:19 +0000 (15:11 +0100)
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>
mm/slub.c

index de74c0e9985e4447dcfbcb95256bade3c42cd712..e725b8d7199d1b953389c5837b66934b57b084eb 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1863,7 +1863,7 @@ check_slabs:
                return NULL;
 }
 
-static int __init setup_slub_debug(char *val)
+static int __init setup_slub_debug(const char *str, const struct kernel_param *kp)
 {
        slab_flags_t flags;
        slab_flags_t global_flags;
@@ -1871,10 +1871,9 @@ static int __init setup_slub_debug(char *val)
        const char *slab_list;
        bool global_slub_debug_changed = false;
        bool slab_list_specified = false;
-       const char *str = val;
 
        global_flags = DEBUG_DEFAULT_FLAGS;
-       if (*str++ != '=' || !*str)
+       if (!str || !*str)
                /*
                 * No options specified. Switch on full debugging.
                 */
@@ -1918,11 +1917,15 @@ out:
             static_branch_unlikely(&init_on_free)) &&
            (slub_debug & SLAB_POISON))
                pr_info("mem auto-init: SLAB_POISON will take precedence over init_on_alloc/init_on_free\n");
-       return 1;
+       return 0;
 }
 
-__setup("slab_debug", setup_slub_debug);
-__setup_param("slub_debug", slub_debug, setup_slub_debug, 0);
+static const struct kernel_param_ops param_ops_slab_debug __initconst = {
+       .flags = KERNEL_PARAM_OPS_FL_NOARG,
+       .set = setup_slub_debug,
+};
+__core_param_cb(slab_debug, &param_ops_slab_debug, NULL, 0);
+__core_param_cb(slub_debug, &param_ops_slab_debug, NULL, 0);
 
 /*
  * kmem_cache_flags - apply debugging options to the cache