FROMLIST: 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/8a3d992a-473a-467b-28a0-4ad2ff60ab82@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Reported-by: Vijayanand Jitta <vjitta@codeaurora.org>
Reviewed-by: Vijayanand Jitta <vjitta@codeaurora.org>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Vinayak Menon <vinmenon@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mark Brown <broonie@kernel.org>

Bug: 195891241
Link: https://lore.kernel.org/lkml/8a3d992a-473a-467b-28a0-4ad2ff60ab82@suse.cz/

Change-Id: I1f94e8897181b230a7b2965b8943f1bdf20e0a49
Signed-off-by: Vijayanand Jitta <vjitta@codeaurora.org>
This commit is contained in:
Vlastimil Babka
2021-08-06 17:14:36 +01:00
committed by Suren Baghdasaryan
parent 2e06e5e6f8
commit 3425d6179e

View File

@@ -1378,12 +1378,13 @@ check_slabs:
static int __init setup_slub_debug(char *str) static int __init setup_slub_debug(char *str)
{ {
slab_flags_t flags; slab_flags_t flags;
slab_flags_t global_flags;
char *saved_str; char *saved_str;
char *slab_list; 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;
slub_debug = DEBUG_DEFAULT_FLAGS; global_flags = DEBUG_DEFAULT_FLAGS;
if (*str++ != '=' || !*str) if (*str++ != '=' || !*str)
/* /*
* No options specified. Switch on full debugging. * No options specified. Switch on full debugging.
@@ -1395,7 +1396,7 @@ static int __init setup_slub_debug(char *str)
str = parse_slub_debug_flags(str, &flags, &slab_list, true); str = parse_slub_debug_flags(str, &flags, &slab_list, true);
if (!slab_list) { if (!slab_list) {
slub_debug = flags; global_flags = flags;
global_slub_debug_changed = true; global_slub_debug_changed = true;
} else { } else {
slab_list_specified = true; slab_list_specified = true;
@@ -1404,16 +1405,18 @@ static int __init setup_slub_debug(char *str)
/* /*
* For backwards compatibility, a single list of flags with list of * For backwards compatibility, a single list of flags with list of
* slabs means debugging is only enabled for those slabs, so the global * slabs means debugging is only changed for those slabs, so the global
* slub_debug should be 0. We can extended that to multiple lists as * 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. * long as there is no option specifying flags without a slab list.
*/ */
if (slab_list_specified) { if (slab_list_specified) {
if (!global_slub_debug_changed) if (!global_slub_debug_changed)
slub_debug = 0; global_flags = slub_debug;
slub_debug_string = saved_str; slub_debug_string = saved_str;
} }
out: out:
slub_debug = global_flags;
if (slub_debug != 0 || slub_debug_string) if (slub_debug != 0 || slub_debug_string)
static_branch_enable(&slub_debug_enabled); static_branch_enable(&slub_debug_enabled);
if ((static_branch_unlikely(&init_on_alloc) || if ((static_branch_unlikely(&init_on_alloc) ||