linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] slab: Ignore internal flags in cache creation
@ 2012-09-25 11:17 Glauber Costa
  2012-09-25 16:26 ` Christoph Lameter
  0 siblings, 1 reply; 26+ messages in thread
From: Glauber Costa @ 2012-09-25 11:17 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, Michal Hocko, Glauber Costa, Christoph Lameter,
	Pekka Enberg, David Rientjes

Some flags are used internally by the allocators for management
purposes. One example of that is the CFLGS_OFF_SLAB flag that slab uses
to mark that the metadata for that cache is stored outside of the slab.

No cache should ever pass those as a creation flags. We can just ignore
this bit if it happens to be passed (such as when duplicating a cache in
the kmem memcg patches)

Signed-off-by: Glauber Costa <glommer@parallels.com>
CC: Christoph Lameter <cl@linux.com>
CC: Pekka Enberg <penberg@cs.helsinki.fi>
CC: David Rientjes <rientjes@google.com>
---
 include/linux/slab.h | 4 ++++
 mm/slab_common.c     | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 0dd2dfa..437c07e 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -79,6 +79,10 @@
 /* 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 */
+
+/* The last flags are reserved for specific internal flags of the allocators */
+#define SLAB_INTERNAL 0xF0000000UL
+
 /*
  * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests.
  *
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 9c21725..359ef36 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -107,6 +107,11 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, size_t align
 	if (!kmem_cache_sanity_check(name, size) == 0)
 		goto out_locked;
 
+	/*
+	 * Clean any possible internal flags the caller may have passed.
+	 * We'll make those decisions ourselves.
+	 */
+	flags &= ~SLAB_INTERNAL;
 
 	s = __kmem_cache_alias(name, size, align, flags, ctor);
 	if (s)
-- 
1.7.11.4

--
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	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2012-10-01 17:54 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-25 11:17 [PATCH] slab: Ignore internal flags in cache creation Glauber Costa
2012-09-25 16:26 ` Christoph Lameter
2012-09-26  0:46   ` David Rientjes
2012-09-26  8:43     ` Glauber Costa
2012-09-27  1:16       ` David Rientjes
2012-09-27  6:59         ` Glauber Costa
2012-09-27 22:56           ` David Rientjes
2012-09-28  7:46             ` Glauber Costa
2012-09-28 20:25               ` David Rientjes
2012-09-28 14:12             ` Christoph Lameter
2012-09-28 20:39               ` David Rientjes
2012-09-28 21:20                 ` Christoph Lameter
2012-09-28 23:11                   ` David Rientjes
2012-10-01 17:54                     ` Christoph Lameter
2012-10-01  7:28                 ` Pekka Enberg
2012-10-01  7:58                   ` Glauber Costa
2012-09-27 13:54         ` Christoph Lameter
2012-09-27 22:50           ` David Rientjes
2012-09-28 14:04             ` Christoph Lameter
2012-09-28 20:36               ` David Rientjes
2012-09-26 14:57     ` Christoph Lameter
2012-09-27  1:12       ` David Rientjes
2012-09-27 13:57         ` Christoph Lameter
2012-09-27 22:52           ` David Rientjes
2012-09-28 14:10             ` Christoph Lameter
2012-09-28 20:30               ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox