Skip to content

Commit

Permalink
mm: slub: fix slub_debug disabling for list of slabs
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tehcaster authored and torvalds committed Aug 14, 2021
1 parent 1ed7ce5 commit a7f1d48
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,12 +1400,13 @@ parse_slub_debug_flags(char *str, slab_flags_t *flags, char **slabs, bool init)
static int __init setup_slub_debug(char *str)
{
slab_flags_t flags;
slab_flags_t global_flags;
char *saved_str;
char *slab_list;
bool global_slub_debug_changed = false;
bool slab_list_specified = false;

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

if (!slab_list) {
slub_debug = flags;
global_flags = flags;
global_slub_debug_changed = true;
} else {
slab_list_specified = true;
Expand All @@ -1426,16 +1427,18 @@ static int __init setup_slub_debug(char *str)

/*
* For backwards compatibility, a single list of flags with list of
* slabs means debugging is only enabled for those slabs, so the global
* slub_debug should be 0. We can extended that to multiple lists as
* slabs means debugging is only changed for those slabs, so the global
* slub_debug should be unchanged (0 or DEBUG_DEFAULT_FLAGS, depending
* on CONFIG_SLUB_DEBUG_ON). We can extended that to multiple lists as
* long as there is no option specifying flags without a slab list.
*/
if (slab_list_specified) {
if (!global_slub_debug_changed)
slub_debug = 0;
global_flags = slub_debug;
slub_debug_string = saved_str;
}
out:
slub_debug = global_flags;
if (slub_debug != 0 || slub_debug_string)
static_branch_enable(&slub_debug_enabled);
else
Expand Down

0 comments on commit a7f1d48

Please sign in to comment.