linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
To: linux-mm@kvack.org, Christoph Lameter <cl@linux.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] mm/slub: disable merging after enabling debug in runtime
Date: Tue, 14 Jul 2015 16:17:05 +0300	[thread overview]
Message-ID: <20150714131705.21442.99279.stgit@buzz> (raw)
In-Reply-To: <20150714131704.21442.17939.stgit@buzz>

Enabling debug in runtime breaks creation of new kmem caches:
they have incompatible flags thus cannot be merged but unique
names are taken by existing caches.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 mm/slab.h        |    2 ++
 mm/slab_common.c |    2 +-
 mm/slub.c        |    9 ++++++++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/mm/slab.h b/mm/slab.h
index 8da63e4e470f..c8998f1d270f 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -66,6 +66,8 @@ extern struct list_head slab_caches;
 /* The slab cache that manages slab cache information */
 extern struct kmem_cache *kmem_cache;
 
+extern int slab_nomerge;
+
 unsigned long calculate_alignment(unsigned long flags,
 		unsigned long align, unsigned long size);
 
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 3e5f8f29c286..eae96f0e7f29 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -44,7 +44,7 @@ struct kmem_cache *kmem_cache;
  * Merge control. If this is set then no merging of slab caches will occur.
  * (Could be removed. This was introduced to pacify the merge skeptics.)
  */
-static int slab_nomerge;
+int slab_nomerge __read_mostly;
 
 static int __init setup_slab_nomerge(char *str)
 {
diff --git a/mm/slub.c b/mm/slub.c
index 4497cae6a914..94300ced4c96 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4610,6 +4610,7 @@ static ssize_t sanity_checks_store(struct kmem_cache *s,
 	if (buf[0] == '1') {
 		s->flags &= ~__CMPXCHG_DOUBLE;
 		s->flags |= SLAB_DEBUG_FREE;
+		slab_nomerge = 1;
 	}
 	return length;
 }
@@ -4635,6 +4636,7 @@ static ssize_t trace_store(struct kmem_cache *s, const char *buf,
 	if (buf[0] == '1') {
 		s->flags &= ~__CMPXCHG_DOUBLE;
 		s->flags |= SLAB_TRACE;
+		slab_nomerge = 1;
 	}
 	return length;
 }
@@ -4655,6 +4657,7 @@ static ssize_t red_zone_store(struct kmem_cache *s,
 	if (buf[0] == '1') {
 		s->flags &= ~__CMPXCHG_DOUBLE;
 		s->flags |= SLAB_RED_ZONE;
+		slab_nomerge = 1;
 	}
 	calculate_sizes(s, -1);
 	return length;
@@ -4676,6 +4679,7 @@ static ssize_t poison_store(struct kmem_cache *s,
 	if (buf[0] == '1') {
 		s->flags &= ~__CMPXCHG_DOUBLE;
 		s->flags |= SLAB_POISON;
+		slab_nomerge = 1;
 	}
 	calculate_sizes(s, -1);
 	return length;
@@ -4697,6 +4701,7 @@ static ssize_t store_user_store(struct kmem_cache *s,
 	if (buf[0] == '1') {
 		s->flags &= ~__CMPXCHG_DOUBLE;
 		s->flags |= SLAB_STORE_USER;
+		slab_nomerge = 1;
 	}
 	calculate_sizes(s, -1);
 	return length;
@@ -4752,8 +4757,10 @@ static ssize_t failslab_store(struct kmem_cache *s, const char *buf,
 		return -EINVAL;
 
 	s->flags &= ~SLAB_FAILSLAB;
-	if (buf[0] == '1')
+	if (buf[0] == '1') {
 		s->flags |= SLAB_FAILSLAB;
+		slab_nomerge = 1;
+	}
 	return length;
 }
 SLAB_ATTR(failslab);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2015-07-14 13:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14 13:17 [PATCH 1/2] mm/slub: fix slab double-free in case of duplicate sysfs filename Konstantin Khlebnikov
2015-07-14 13:17 ` Konstantin Khlebnikov [this message]
2015-07-14 18:11   ` [PATCH 2/2] mm/slub: disable merging after enabling debug in runtime Christoph Lameter
2015-07-14 20:21     ` Konstantin Khlebnikov
2015-07-14 21:18       ` Christoph Lameter
2015-07-17  9:37         ` Konstantin Khlebnikov
2015-07-17 15:09           ` Christoph Lameter
2015-07-17 15:25             ` Konstantin Khlebnikov
2015-07-14 18:11 ` [PATCH 1/2] mm/slub: fix slab double-free in case of duplicate sysfs filename Christoph Lameter
2015-07-16  0:27 ` David Rientjes

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=20150714131705.21442.99279.stgit@buzz \
    --to=khlebnikov@yandex-team.ru \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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).