slab: constify slab debug strings

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>
Reviewed-by: Christoph Lameter <cl@gentwo.org>
Link: https://patch.msgid.link/819095b921f6ae03bb54fd69ee4020e2a3aef675.1761324765.git.ptesarik@suse.com
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
This commit is contained in:
Petr Tesarik 2025-10-24 19:06:52 +02:00 committed by Vlastimil Babka
parent dcb6fa37fd
commit d3722ff57e
1 changed files with 10 additions and 9 deletions

View File

@ -978,7 +978,7 @@ static slab_flags_t slub_debug = DEBUG_DEFAULT_FLAGS;
static slab_flags_t slub_debug; static slab_flags_t slub_debug;
#endif #endif
static char *slub_debug_string; static const char *slub_debug_string __ro_after_init;
static int disable_higher_order_debug; 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 * returns the start of next block if there's any, or NULL
*/ */
static char * static const char *
parse_slub_debug_flags(char *str, slab_flags_t *flags, char **slabs, bool init) parse_slub_debug_flags(const char *str, slab_flags_t *flags, const char **slabs, bool init)
{ {
bool higher_order_disable = false; 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; 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 flags;
slab_flags_t global_flags; slab_flags_t global_flags;
char *saved_str; const char *saved_str;
char *slab_list; const char *slab_list;
bool global_slub_debug_changed = false; bool global_slub_debug_changed = false;
bool slab_list_specified = false; bool slab_list_specified = false;
const char *str = val;
global_flags = DEBUG_DEFAULT_FLAGS; global_flags = DEBUG_DEFAULT_FLAGS;
if (*str++ != '=' || !*str) 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) slab_flags_t kmem_cache_flags(slab_flags_t flags, const char *name)
{ {
char *iter; const char *iter;
size_t len; size_t len;
char *next_block; const char *next_block;
slab_flags_t block_flags; slab_flags_t block_flags;
slab_flags_t slub_debug_local = slub_debug; 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; continue;
/* Found a block that has a slab list, search it */ /* Found a block that has a slab list, search it */
while (*iter) { while (*iter) {
char *end, *glob; const char *end, *glob;
size_t cmplen; size_t cmplen;
end = strchrnul(iter, ','); end = strchrnul(iter, ',');