Skip to contentSkip to conversation

slab: mempool-backed object caches

PATCH New Pekka Enberg 1 participant 1 message Jan 28, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 slab: mempool-backed object caches

Hi Matthew,

This completely untested patch adds kmem_cache_create_mempool which creates a mempool-backed object cache. It wont work as-is (we're not checking page order, for example) but you should get the idea.

The good part is that now you can create object caches for many critical allocations which can share the same subsystem-specific mempool.

---

 include/linux/slab.h |   15 ++++++++++++---
 mm/slab.c            |   44 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 52 insertions(+), 7 deletions(-)
include/linux/slab.h +12 -3
Index: 2.6-mm/include/linux/slab.h
===================================================================
@@ -15,6 +15,7 @@ typedef struct kmem_cache kmem_cache_t;
 #include	<linux/gfp.h>
 #include	<linux/init.h>
 #include	<linux/types.h>
+#include	<linux/mempool.h>
 #include	<asm/page.h>		/* kmalloc_sizes.h needs PAGE_SIZE */
 #include	<asm/cache.h>		/* kmalloc_sizes.h needs L1_CACHE_BYTES */
 
@@ -58,9 +59,17 @@ typedef struct kmem_cache kmem_cache_t;
 /* prototypes */
 extern void __init kmem_cache_init(void);
 
-extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long,
-				       void (*)(void *, kmem_cache_t *, unsigned long),
-				       void (*)(void *, kmem_cache_t *, unsigned long));
+typedef void (*kmem_ctor_fn)(void *, kmem_cache_t *, unsigned long);
+typedef void (*kmem_dtor_fn)(void *, kmem_cache_t *, unsigned long);
+
+extern struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
+					    unsigned long, kmem_ctor_fn,
+					    kmem_dtor_fn);
+
+extern struct kmem_cache *kmem_cache_create_mempool(const char *, size_t,
+						    size_t, unsigned long,
+						    kmem_ctor_fn,
+						    kmem_dtor_fn, mempool_t *);
 extern int kmem_cache_destroy(kmem_cache_t *);
 extern int kmem_cache_shrink(kmem_cache_t *);
 extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t);
mm/slab.c +40 -4

76 lines not on this page · raw message

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