diff options
author | David Rientjes <rientjes@google.com> | 2015-04-15 19:14:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-15 19:35:18 -0400 |
commit | e244c9e66f6197f55f6fbb2d5e70714e262cc595 (patch) | |
tree | 97c010b71008486c3ff66a81e7bcc0e957f0f826 /mm/mempool.c | |
parent | ee1462458cb543bbcfd379176bbba0d4bd052b7f (diff) |
mm, mempool: disallow mempools based on slab caches with constructors
All occurrences of mempools based on slab caches with object constructors
have been removed from the tree, so disallow creating them.
We can only dereference mem->ctor in mm/mempool.c without including
mm/slab.h in include/linux/mempool.h. So simply note the restriction,
just like the comment restricting usage of __GFP_ZERO, and warn on kernels
with CONFIG_DEBUG_VM() if such a mempool is allocated from.
We don't want to incur this check on every element allocation, so use
VM_BUG_ON().
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: Dave Kleikamp <shaggy@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/mempool.c')
-rw-r--r-- | mm/mempool.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/mm/mempool.c b/mm/mempool.c index 949970db2874..b60fb85526ed 100644 --- a/mm/mempool.c +++ b/mm/mempool.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/mempool.h> | 15 | #include <linux/mempool.h> |
16 | #include <linux/blkdev.h> | 16 | #include <linux/blkdev.h> |
17 | #include <linux/writeback.h> | 17 | #include <linux/writeback.h> |
18 | #include "slab.h" | ||
18 | 19 | ||
19 | static void add_element(mempool_t *pool, void *element) | 20 | static void add_element(mempool_t *pool, void *element) |
20 | { | 21 | { |
@@ -334,6 +335,7 @@ EXPORT_SYMBOL(mempool_free); | |||
334 | void *mempool_alloc_slab(gfp_t gfp_mask, void *pool_data) | 335 | void *mempool_alloc_slab(gfp_t gfp_mask, void *pool_data) |
335 | { | 336 | { |
336 | struct kmem_cache *mem = pool_data; | 337 | struct kmem_cache *mem = pool_data; |
338 | VM_BUG_ON(mem->ctor); | ||
337 | return kmem_cache_alloc(mem, gfp_mask); | 339 | return kmem_cache_alloc(mem, gfp_mask); |
338 | } | 340 | } |
339 | EXPORT_SYMBOL(mempool_alloc_slab); | 341 | EXPORT_SYMBOL(mempool_alloc_slab); |