linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Eric Farman <farman@linux.ibm.com>
To: vbabka@suse.cz
Cc: akpm@linux-foundation.org, cl@linux.com, farman@linux.ibm.com,
	iamjoonsoo.kim@lge.com, keescook@chromium.org,
	linux-mm@kvack.org, penberg@kernel.org, rientjes@google.com
Subject: [PATCH v2] mm, slub: Restore initial kmem_cache flags
Date: Wed, 30 Sep 2020 18:19:31 +0200	[thread overview]
Message-ID: <20200930161931.28575-1-farman@linux.ibm.com> (raw)
In-Reply-To: <a0682107-3654-8471-28c7-d4007a2867b5@suse.cz>

The routine that applies debug flags to the kmem_cache slabs
inadvertantly prevents non-debug flags from being applied to
those same objects. That is, if slub_debug=<flag>,<slab> is
specified, non-debugged slabs will end up having flags of zero,
and the slabs may be unusable.

Fix this by including the input flags for non-matching slabs
with the contents of slub_debug, so that the caches are
created as expected alongside any debugging options that may
be requested. With this, we can remove the check for a NULL
slub_debug_string, since it's covered by the loop itself.

Fixes: e17f1dfba37b ("mm, slub: extend slub_debug syntax for multiple blocks")
Signed-off-by: Eric Farman <farman@linux.ibm.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
---
 v2: OR return values per Vlastimil, applied his Ack
 v1: https://lore.kernel.org/linux-mm/20200930112612.76109-1-farman@linux.ibm.com/T/#t
---
 mm/slub.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index d4177aecedf6..6d3574013b2f 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1413,10 +1413,6 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
 	char *next_block;
 	slab_flags_t block_flags;
 
-	/* If slub_debug = 0, it folds into the if conditional. */
-	if (!slub_debug_string)
-		return flags | slub_debug;
-
 	len = strlen(name);
 	next_block = slub_debug_string;
 	/* Go through all blocks of debug options, see if any matches our slab's name */
@@ -1450,7 +1446,7 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
 		}
 	}
 
-	return slub_debug;
+	return flags | slub_debug;
 }
 #else /* !CONFIG_SLUB_DEBUG */
 static inline void setup_object_debug(struct kmem_cache *s,
-- 
2.17.1



      reply	other threads:[~2020-09-30 16:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30 11:26 [PATCH 0/1] Fix slub_debug on 5.9-rc Eric Farman
2020-09-30 11:26 ` [PATCH 1/1] mm, slub: Restore initial kmem_cache flags Eric Farman
2020-09-30 11:37   ` Vlastimil Babka
2020-09-30 13:06     ` Eric Farman
2020-09-30 13:54       ` Vlastimil Babka
2020-09-30 16:19         ` Eric Farman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200930161931.28575-1-farman@linux.ibm.com \
    --to=farman@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=keescook@chromium.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).