linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Device-mapper submission 1/7
@ 2002-10-15 17:41 Joe Thornber
  0 siblings, 0 replies; only message in thread
From: Joe Thornber @ 2002-10-15 17:41 UTC (permalink / raw)
  To: Linux Mailing List, Linus Torvalds, Dave Jones

I'm hereby submitting the device-mapper patches for inclusion in 2.5.
All of the patches can be pulled using bitkeeper from:

   bk://device-mapper@device-mapper.bkbits.net/dm-submission

[mempool]
Most people use mempools in conjuction with slabs, this defines
an allocator and free function to simplify this.

--- a/include/linux/mempool.h	Tue Oct 15 18:24:31 2002
+++ b/include/linux/mempool.h	Tue Oct 15 18:24:31 2002
@@ -27,4 +27,11 @@
 extern void * mempool_alloc(mempool_t *pool, int gfp_mask);
 extern void mempool_free(void *element, mempool_t *pool);
 
+/*
+ * A mempool_alloc_t and mempool_free_t that get the memory from
+ * a slab that is passed in through pool_data.
+ */
+void *mempool_alloc_slab(int gfp_mask, void *pool_data);
+void mempool_free_slab(void *element, void *pool_data);
+
 #endif /* _LINUX_MEMPOOL_H */
--- a/mm/mempool.c	Tue Oct 15 18:24:31 2002
+++ b/mm/mempool.c	Tue Oct 15 18:24:31 2002
@@ -259,8 +259,25 @@
 	pool->free(element, pool->pool_data);
 }
 
+/*
+ * A commonly used alloc and free fn.
+ */
+void *mempool_alloc_slab(int gfp_mask, void *pool_data)
+{
+	kmem_cache_t *mem = (kmem_cache_t *) pool_data;
+	return kmem_cache_alloc(mem, gfp_mask);
+}
+
+void mempool_free_slab(void *element, void *pool_data)
+{
+	kmem_cache_t *mem = (kmem_cache_t *) pool_data;
+	kmem_cache_free(mem, element);
+}
+
 EXPORT_SYMBOL(mempool_create);
 EXPORT_SYMBOL(mempool_resize);
 EXPORT_SYMBOL(mempool_destroy);
 EXPORT_SYMBOL(mempool_alloc);
 EXPORT_SYMBOL(mempool_free);
+EXPORT_SYMBOL(mempool_alloc_slab);
+EXPORT_SYMBOL(mempool_free_slab);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-15 17:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-15 17:41 [PATCH] Device-mapper submission 1/7 Joe Thornber

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