* [PATCH 1/3] slab: constify slab debug strings
2025-10-24 17:06 [PATCH 0/3] slab: switch away from the legacy param parser Petr Tesarik
@ 2025-10-24 17:06 ` Petr Tesarik
2025-10-24 17:44 ` Christoph Lameter (Ampere)
2025-10-29 9:54 ` Harry Yoo
2025-10-24 17:06 ` [PATCH 2/3] slab: convert setup_slub_debug() to use __core_param_cb() Petr Tesarik
` (2 subsequent siblings)
3 siblings, 2 replies; 12+ messages in thread
From: Petr Tesarik @ 2025-10-24 17:06 UTC (permalink / raw)
To: Vlastimil Babka, Andrew Morton, Christoph Lameter,
David Rientjes, Roman Gushchin, Harry Yoo
Cc: linux-mm, linux-kernel, Petr Tesarik
Since the string passed to slab_debug is never modified, use pointers to
const char in all places where it is processed.
No functional changes intended.
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
mm/slub.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 708848d3512c5..26faebcf27a2b 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -978,7 +978,7 @@ static slab_flags_t slub_debug = DEBUG_DEFAULT_FLAGS;
static slab_flags_t slub_debug;
#endif
-static char *slub_debug_string;
+static const char *slub_debug_string __ro_after_init;
static int disable_higher_order_debug;
/*
@@ -1785,8 +1785,8 @@ static inline int free_consistency_checks(struct kmem_cache *s,
*
* returns the start of next block if there's any, or NULL
*/
-static char *
-parse_slub_debug_flags(char *str, slab_flags_t *flags, char **slabs, bool init)
+static const char *
+parse_slub_debug_flags(const char *str, slab_flags_t *flags, const char **slabs, bool init)
{
bool higher_order_disable = false;
@@ -1863,14 +1863,15 @@ parse_slub_debug_flags(char *str, slab_flags_t *flags, char **slabs, bool init)
return NULL;
}
-static int __init setup_slub_debug(char *str)
+static int __init setup_slub_debug(char *val)
{
slab_flags_t flags;
slab_flags_t global_flags;
- char *saved_str;
- char *slab_list;
+ const char *saved_str;
+ 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)
@@ -1935,9 +1936,9 @@ __setup_param("slub_debug", slub_debug, setup_slub_debug, 0);
*/
slab_flags_t kmem_cache_flags(slab_flags_t flags, const char *name)
{
- char *iter;
+ const char *iter;
size_t len;
- char *next_block;
+ const char *next_block;
slab_flags_t block_flags;
slab_flags_t slub_debug_local = slub_debug;
@@ -1961,7 +1962,7 @@ slab_flags_t kmem_cache_flags(slab_flags_t flags, const char *name)
continue;
/* Found a block that has a slab list, search it */
while (*iter) {
- char *end, *glob;
+ const char *end, *glob;
size_t cmplen;
end = strchrnul(iter, ',');
--
2.51.0
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 1/3] slab: constify slab debug strings
2025-10-24 17:06 ` [PATCH 1/3] slab: constify slab debug strings Petr Tesarik
@ 2025-10-24 17:44 ` Christoph Lameter (Ampere)
2025-10-29 9:54 ` Harry Yoo
1 sibling, 0 replies; 12+ messages in thread
From: Christoph Lameter (Ampere) @ 2025-10-24 17:44 UTC (permalink / raw)
To: Petr Tesarik
Cc: Vlastimil Babka, Andrew Morton, David Rientjes, Roman Gushchin,
Harry Yoo, linux-mm
Reviewed-by: Christoph Lameter <cl@gentwo.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] slab: constify slab debug strings
2025-10-24 17:06 ` [PATCH 1/3] slab: constify slab debug strings Petr Tesarik
2025-10-24 17:44 ` Christoph Lameter (Ampere)
@ 2025-10-29 9:54 ` Harry Yoo
1 sibling, 0 replies; 12+ messages in thread
From: Harry Yoo @ 2025-10-29 9:54 UTC (permalink / raw)
To: Petr Tesarik
Cc: Vlastimil Babka, Andrew Morton, Christoph Lameter,
David Rientjes, Roman Gushchin, linux-mm, linux-kernel
On Fri, Oct 24, 2025 at 07:06:52PM +0200, Petr Tesarik wrote:
> Since the string passed to slab_debug is never modified, use pointers to
> const char in all places where it is processed.
>
> No functional changes intended.
>
> Signed-off-by: Petr Tesarik <ptesarik@suse.com>
> ---
Looks good to me,
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] slab: convert setup_slub_debug() to use __core_param_cb()
2025-10-24 17:06 [PATCH 0/3] slab: switch away from the legacy param parser Petr Tesarik
2025-10-24 17:06 ` [PATCH 1/3] slab: constify slab debug strings Petr Tesarik
@ 2025-10-24 17:06 ` Petr Tesarik
2025-10-29 10:16 ` Harry Yoo
2025-10-24 17:06 ` [PATCH 3/3] slab: use new API for remaining command line parameters Petr Tesarik
2025-10-27 15:06 ` [PATCH 0/3] slab: switch away from the legacy param parser Vlastimil Babka
3 siblings, 1 reply; 12+ messages in thread
From: Petr Tesarik @ 2025-10-24 17:06 UTC (permalink / raw)
To: Vlastimil Babka, Andrew Morton, Christoph Lameter,
David Rientjes, Roman Gushchin, Harry Yoo
Cc: linux-mm, linux-kernel, Petr Tesarik
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>
---
mm/slub.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 26faebcf27a2b..b124087b95f32 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1863,7 +1863,7 @@ parse_slub_debug_flags(const char *str, slab_flags_t *flags, const char **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 @@ static int __init setup_slub_debug(char *val)
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, ¶m_ops_slab_debug, NULL, 0);
+__core_param_cb(slub_debug, ¶m_ops_slab_debug, NULL, 0);
/*
* kmem_cache_flags - apply debugging options to the cache
--
2.51.0
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 2/3] slab: convert setup_slub_debug() to use __core_param_cb()
2025-10-24 17:06 ` [PATCH 2/3] slab: convert setup_slub_debug() to use __core_param_cb() Petr Tesarik
@ 2025-10-29 10:16 ` Harry Yoo
0 siblings, 0 replies; 12+ messages in thread
From: Harry Yoo @ 2025-10-29 10:16 UTC (permalink / raw)
To: Petr Tesarik
Cc: Vlastimil Babka, Andrew Morton, Christoph Lameter,
David Rientjes, Roman Gushchin, linux-mm, linux-kernel
On Fri, Oct 24, 2025 at 07:06:53PM +0200, Petr Tesarik wrote:
> 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>
> ---
Good byte to slub_debug_yada_yada_gotta_love_this=hail_satan! :'(
Looks good to me,
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] slab: use new API for remaining command line parameters
2025-10-24 17:06 [PATCH 0/3] slab: switch away from the legacy param parser Petr Tesarik
2025-10-24 17:06 ` [PATCH 1/3] slab: constify slab debug strings Petr Tesarik
2025-10-24 17:06 ` [PATCH 2/3] slab: convert setup_slub_debug() to use __core_param_cb() Petr Tesarik
@ 2025-10-24 17:06 ` Petr Tesarik
2025-10-29 10:52 ` Harry Yoo
2025-10-27 15:06 ` [PATCH 0/3] slab: switch away from the legacy param parser Vlastimil Babka
3 siblings, 1 reply; 12+ messages in thread
From: Petr Tesarik @ 2025-10-24 17:06 UTC (permalink / raw)
To: Vlastimil Babka, Andrew Morton, Christoph Lameter,
David Rientjes, Roman Gushchin, Harry Yoo
Cc: linux-mm, linux-kernel, Petr Tesarik
Use core_param() and __core_param_cb() instead of __setup() or
__setup_param() to improve syntax checking and error messages.
Replace get_option() with kstrtouint(), because:
* the latter accepts a pointer to const char,
* these parameters should not accept ranges,
* error value can be passed directly to parser.
There is one more change apart from the parsing of numeric parameters:
slub_strict_numa parameter name must match exactly. Before this patch the
kernel would silently accept any option that starts with the name as an
undocumented alias.
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
mm/slub.c | 57 +++++++++++++++++++++++++++++++++----------------------
1 file changed, 34 insertions(+), 23 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index b124087b95f32..482460ff3abca 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -8119,46 +8119,53 @@ void __kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct slab *slab)
* Kmalloc subsystem
*******************************************************************/
-static int __init setup_slub_min_order(char *str)
+static int __init setup_slub_min_order(const char *str, const struct kernel_param *kp)
{
- get_option(&str, (int *)&slub_min_order);
+ int ret;
+
+ ret = kstrtouint(str, 0, &slub_min_order);
+ if (ret)
+ return ret;
if (slub_min_order > slub_max_order)
slub_max_order = slub_min_order;
- return 1;
+ return 0;
}
-__setup("slab_min_order=", setup_slub_min_order);
-__setup_param("slub_min_order=", slub_min_order, setup_slub_min_order, 0);
-
+static const struct kernel_param_ops param_ops_slab_min_order __initconst = {
+ .set = setup_slub_min_order,
+};
+__core_param_cb(slab_min_order, ¶m_ops_slab_min_order, &slub_min_order, 0);
+__core_param_cb(slub_min_order, ¶m_ops_slab_min_order, &slub_min_order, 0);
-static int __init setup_slub_max_order(char *str)
+static int __init setup_slub_max_order(const char *str, const struct kernel_param *kp)
{
- get_option(&str, (int *)&slub_max_order);
+ int ret;
+
+ ret = kstrtouint(str, 0, &slub_max_order);
+ if (ret)
+ return ret;
+
slub_max_order = min_t(unsigned int, slub_max_order, MAX_PAGE_ORDER);
if (slub_min_order > slub_max_order)
slub_min_order = slub_max_order;
- return 1;
+ return 0;
}
-__setup("slab_max_order=", setup_slub_max_order);
-__setup_param("slub_max_order=", slub_max_order, setup_slub_max_order, 0);
-
-static int __init setup_slub_min_objects(char *str)
-{
- get_option(&str, (int *)&slub_min_objects);
-
- return 1;
-}
+static const struct kernel_param_ops param_ops_slab_max_order __initconst = {
+ .set = setup_slub_max_order,
+};
+__core_param_cb(slab_max_order, ¶m_ops_slab_max_order, &slub_max_order, 0);
+__core_param_cb(slub_max_order, ¶m_ops_slab_max_order, &slub_max_order, 0);
-__setup("slab_min_objects=", setup_slub_min_objects);
-__setup_param("slub_min_objects=", slub_min_objects, setup_slub_min_objects, 0);
+core_param(slab_min_objects, slub_min_objects, uint, 0);
+core_param(slub_min_objects, slub_min_objects, uint, 0);
#ifdef CONFIG_NUMA
-static int __init setup_slab_strict_numa(char *str)
+static int __init setup_slab_strict_numa(const char *str, const struct kernel_param *kp)
{
if (nr_node_ids > 1) {
static_branch_enable(&strict_numa);
@@ -8167,10 +8174,14 @@ static int __init setup_slab_strict_numa(char *str)
pr_warn("slab_strict_numa parameter set on non NUMA system.\n");
}
- return 1;
+ return 0;
}
-__setup("slab_strict_numa", setup_slab_strict_numa);
+static const struct kernel_param_ops param_ops_slab_strict_numa __initconst = {
+ .flags = KERNEL_PARAM_OPS_FL_NOARG,
+ .set = setup_slab_strict_numa,
+};
+__core_param_cb(slab_strict_numa, ¶m_ops_slab_strict_numa, NULL, 0);
#endif
--
2.51.0
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 3/3] slab: use new API for remaining command line parameters
2025-10-24 17:06 ` [PATCH 3/3] slab: use new API for remaining command line parameters Petr Tesarik
@ 2025-10-29 10:52 ` Harry Yoo
2025-10-30 13:32 ` Petr Tesarik
0 siblings, 1 reply; 12+ messages in thread
From: Harry Yoo @ 2025-10-29 10:52 UTC (permalink / raw)
To: Petr Tesarik
Cc: Vlastimil Babka, Andrew Morton, Christoph Lameter,
David Rientjes, Roman Gushchin, linux-mm, linux-kernel
On Fri, Oct 24, 2025 at 07:06:54PM +0200, Petr Tesarik wrote:
> Use core_param() and __core_param_cb() instead of __setup() or
> __setup_param() to improve syntax checking and error messages.
>
> Replace get_option() with kstrtouint(), because:
> * the latter accepts a pointer to const char,
> * these parameters should not accept ranges,
> * error value can be passed directly to parser.
>
> There is one more change apart from the parsing of numeric parameters:
> slub_strict_numa parameter name must match exactly. Before this patch the
nit: ^ slab_strict_numa
> kernel would silently accept any option that starts with the name as an
> undocumented alias.
>
> Signed-off-by: Petr Tesarik <ptesarik@suse.com>
> ---
Looks good to me,
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] slab: use new API for remaining command line parameters
2025-10-29 10:52 ` Harry Yoo
@ 2025-10-30 13:32 ` Petr Tesarik
2025-10-30 13:35 ` Vlastimil Babka
0 siblings, 1 reply; 12+ messages in thread
From: Petr Tesarik @ 2025-10-30 13:32 UTC (permalink / raw)
To: Harry Yoo
Cc: Vlastimil Babka, Andrew Morton, Christoph Lameter,
David Rientjes, Roman Gushchin, linux-mm, linux-kernel
On Wed, 29 Oct 2025 19:52:46 +0900
Harry Yoo <harry.yoo@oracle.com> wrote:
> On Fri, Oct 24, 2025 at 07:06:54PM +0200, Petr Tesarik wrote:
> > Use core_param() and __core_param_cb() instead of __setup() or
> > __setup_param() to improve syntax checking and error messages.
> >
> > Replace get_option() with kstrtouint(), because:
> > * the latter accepts a pointer to const char,
> > * these parameters should not accept ranges,
> > * error value can be passed directly to parser.
> >
> > There is one more change apart from the parsing of numeric parameters:
> > slub_strict_numa parameter name must match exactly. Before this patch the
>
> nit: ^ slab_strict_numa
Indeed.
Petr T
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] slab: use new API for remaining command line parameters
2025-10-30 13:32 ` Petr Tesarik
@ 2025-10-30 13:35 ` Vlastimil Babka
0 siblings, 0 replies; 12+ messages in thread
From: Vlastimil Babka @ 2025-10-30 13:35 UTC (permalink / raw)
To: Petr Tesarik, Harry Yoo
Cc: Andrew Morton, Christoph Lameter, David Rientjes, Roman Gushchin,
linux-mm, linux-kernel
On 10/30/25 14:32, Petr Tesarik wrote:
> On Wed, 29 Oct 2025 19:52:46 +0900
> Harry Yoo <harry.yoo@oracle.com> wrote:
>
>> On Fri, Oct 24, 2025 at 07:06:54PM +0200, Petr Tesarik wrote:
>> > Use core_param() and __core_param_cb() instead of __setup() or
>> > __setup_param() to improve syntax checking and error messages.
>> >
>> > Replace get_option() with kstrtouint(), because:
>> > * the latter accepts a pointer to const char,
>> > * these parameters should not accept ranges,
>> > * error value can be passed directly to parser.
>> >
>> > There is one more change apart from the parsing of numeric parameters:
>> > slub_strict_numa parameter name must match exactly. Before this patch the
>>
>> nit: ^ slab_strict_numa
Ah right, thanks, fixed up.
> Indeed.
>
> Petr T
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/3] slab: switch away from the legacy param parser
2025-10-24 17:06 [PATCH 0/3] slab: switch away from the legacy param parser Petr Tesarik
` (2 preceding siblings ...)
2025-10-24 17:06 ` [PATCH 3/3] slab: use new API for remaining command line parameters Petr Tesarik
@ 2025-10-27 15:06 ` Vlastimil Babka
2025-10-30 11:36 ` Petr Tesarik
3 siblings, 1 reply; 12+ messages in thread
From: Vlastimil Babka @ 2025-10-27 15:06 UTC (permalink / raw)
To: Petr Tesarik, Andrew Morton, Christoph Lameter, David Rientjes,
Roman Gushchin, Harry Yoo
Cc: linux-mm, linux-kernel
On 10/24/25 19:06, Petr Tesarik wrote:
> The handling of legacy __setup() parameters has some confusing quirks.
> Instead of fixing them, convert the code to struct kerenel_param, which
> is a saner API.
>
> Note that parameters defined with core_param() and __core_param_cb() are
> parsed early in start_kernel(). Do not confuse them with core_param_cb(),
> which are processed at a later stage.
Thanks! Added to slab/for-next
> Petr Tesarik (3):
> slab: constify slab debug strings
> slab: convert setup_slub_debug() to use __core_param_cb()
> slab: use core_param for remaining command line parameters
>
> mm/slub.c | 87 ++++++++++++++++++++++++++++++++-----------------------
> 1 file changed, 51 insertions(+), 36 deletions(-)
>
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 0/3] slab: switch away from the legacy param parser
2025-10-27 15:06 ` [PATCH 0/3] slab: switch away from the legacy param parser Vlastimil Babka
@ 2025-10-30 11:36 ` Petr Tesarik
0 siblings, 0 replies; 12+ messages in thread
From: Petr Tesarik @ 2025-10-30 11:36 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Andrew Morton, Christoph Lameter, David Rientjes, Roman Gushchin,
Harry Yoo, linux-mm, linux-kernel
On Mon, 27 Oct 2025 16:06:21 +0100
Vlastimil Babka <vbabka@suse.cz> wrote:
> On 10/24/25 19:06, Petr Tesarik wrote:
> > The handling of legacy __setup() parameters has some confusing quirks.
> > Instead of fixing them, convert the code to struct kerenel_param, which
> > is a saner API.
> >
> > Note that parameters defined with core_param() and __core_param_cb() are
> > parsed early in start_kernel(). Do not confuse them with core_param_cb(),
> > which are processed at a later stage.
>
> Thanks! Added to slab/for-next
Thank you! Appreciated.
Petr T
^ permalink raw reply [flat|nested] 12+ messages in thread