Skip to content

Commit a7f1d48

Browse files
tehcastertorvalds
authored andcommitted
mm: slub: fix slub_debug disabling for list of slabs
Vijayanand Jitta reports: Consider the scenario where CONFIG_SLUB_DEBUG_ON is set and we would want to disable slub_debug for few slabs. Using boot parameter with slub_debug=-,slab_name syntax doesn't work as expected i.e; only disabling debugging for the specified list of slabs. Instead it disables debugging for all slabs, which is wrong. This patch fixes it by delaying the moment when the global slub_debug flags variable is updated. In case a "slub_debug=-,slab_name" has been passed, the global flags remain as initialized (depending on CONFIG_SLUB_DEBUG_ON enabled or disabled) and are not simply reset to 0. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Vlastimil Babka <[email protected]> Reported-by: Vijayanand Jitta <[email protected]> Reviewed-by: Vijayanand Jitta <[email protected]> Acked-by: David Rientjes <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Vinayak Menon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1ed7ce5 commit a7f1d48

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

mm/slub.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,12 +1400,13 @@ parse_slub_debug_flags(char *str, slab_flags_t *flags, char **slabs, bool init)
14001400
static int __init setup_slub_debug(char *str)
14011401
{
14021402
slab_flags_t flags;
1403+
slab_flags_t global_flags;
14031404
char *saved_str;
14041405
char *slab_list;
14051406
bool global_slub_debug_changed = false;
14061407
bool slab_list_specified = false;
14071408

1408-
slub_debug = DEBUG_DEFAULT_FLAGS;
1409+
global_flags = DEBUG_DEFAULT_FLAGS;
14091410
if (*str++ != '=' || !*str)
14101411
/*
14111412
* No options specified. Switch on full debugging.
@@ -1417,7 +1418,7 @@ static int __init setup_slub_debug(char *str)
14171418
str = parse_slub_debug_flags(str, &flags, &slab_list, true);
14181419

14191420
if (!slab_list) {
1420-
slub_debug = flags;
1421+
global_flags = flags;
14211422
global_slub_debug_changed = true;
14221423
} else {
14231424
slab_list_specified = true;
@@ -1426,16 +1427,18 @@ static int __init setup_slub_debug(char *str)
14261427

14271428
/*
14281429
* For backwards compatibility, a single list of flags with list of
1429-
* slabs means debugging is only enabled for those slabs, so the global
1430-
* slub_debug should be 0. We can extended that to multiple lists as
1430+
* slabs means debugging is only changed for those slabs, so the global
1431+
* slub_debug should be unchanged (0 or DEBUG_DEFAULT_FLAGS, depending
1432+
* on CONFIG_SLUB_DEBUG_ON). We can extended that to multiple lists as
14311433
* long as there is no option specifying flags without a slab list.
14321434
*/
14331435
if (slab_list_specified) {
14341436
if (!global_slub_debug_changed)
1435-
slub_debug = 0;
1437+
global_flags = slub_debug;
14361438
slub_debug_string = saved_str;
14371439
}
14381440
out:
1441+
slub_debug = global_flags;
14391442
if (slub_debug != 0 || slub_debug_string)
14401443
static_branch_enable(&slub_debug_enabled);
14411444
else

0 commit comments

Comments
 (0)