linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm/slab_common: add SLAB_NO_MERGE flag for use when creating slabs
@ 2015-09-01 17:51 Mike Snitzer
  2015-09-01 17:51 ` [PATCH 2/2] dm: disable slab merging for all DM slabs Mike Snitzer
  2015-09-02  1:15 ` [PATCH 1/2] mm/slab_common: add SLAB_NO_MERGE flag for use when creating slabs Dave Chinner
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Snitzer @ 2015-09-01 17:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-mm, riel, david, axboe, dm-devel, anderson

The slab aliasing/merging by default transition went unnoticed (at least
to the DM subsystem).  Add a new SLAB_NO_MERGE flag that allows
individual slabs to be created without slab merging.  This beats forcing
all slabs to be created in this fashion by specifying sl[au]b_nomerge on
the kernel commandline.

DM has historically taken care to have separate named slabs that each
devices' mempool_t are backed by.  These separate slabs are useful --
even if only to aid inspection of DM's memory use (via /proc/slabinfo)
on production systems.

I stumbled onto slab merging as a side-effect of a leak in dm-cache
being attributed to 'kmalloc-96' rather than the expected
'dm_bio_prison_cell' named slab.  Moving forward DM will disable slab
merging for all of DM's slabs by using SLAB_NO_MERGE.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 include/linux/slab.h | 2 ++
 mm/slab.h            | 2 +-
 mm/slab_common.c     | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index a99f0e5..d007407 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -87,6 +87,8 @@
 # define SLAB_FAILSLAB		0x00000000UL
 #endif
 
+#define SLAB_NO_MERGE		0x04000000UL	/* Do not merge with existing slab */
+
 /* The following flags affect the page allocator grouping pages by mobility */
 #define SLAB_RECLAIM_ACCOUNT	0x00020000UL		/* Objects are reclaimable */
 #define SLAB_TEMPORARY		SLAB_RECLAIM_ACCOUNT	/* Objects are short-lived */
diff --git a/mm/slab.h b/mm/slab.h
index 8da63e4..35eb6f4 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -115,7 +115,7 @@ static inline unsigned long kmem_cache_flags(unsigned long object_size,
 
 /* Legal flag mask for kmem_cache_create(), for various configurations */
 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
-			 SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
+			 SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_NO_MERGE)
 
 #if defined(CONFIG_DEBUG_SLAB)
 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 8683110..3a5a8ed 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -35,7 +35,7 @@ struct kmem_cache *kmem_cache;
  */
 #define SLAB_NEVER_MERGE (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \
 		SLAB_TRACE | SLAB_DESTROY_BY_RCU | SLAB_NOLEAKTRACE | \
-		SLAB_FAILSLAB)
+		SLAB_FAILSLAB | SLAB_NO_MERGE)
 
 #define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | SLAB_NOTRACK)
 
-- 
2.3.2 (Apple Git-55)

--
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>

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-02  1:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-01 17:51 [PATCH 1/2] mm/slab_common: add SLAB_NO_MERGE flag for use when creating slabs Mike Snitzer
2015-09-01 17:51 ` [PATCH 2/2] dm: disable slab merging for all DM slabs Mike Snitzer
2015-09-02  1:15 ` [PATCH 1/2] mm/slab_common: add SLAB_NO_MERGE flag for use when creating slabs Dave Chinner

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).