aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mempool.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/mempool.c')
-rw-r--r--mm/mempool.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/mm/mempool.c b/mm/mempool.c
index 9ef13dd68ab7..fe6e05289cc5 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -289,3 +289,45 @@ void mempool_free_slab(void *element, void *pool_data)
289 kmem_cache_free(mem, element); 289 kmem_cache_free(mem, element);
290} 290}
291EXPORT_SYMBOL(mempool_free_slab); 291EXPORT_SYMBOL(mempool_free_slab);
292
293/*
294 * A commonly used alloc and free fn that kmalloc/kfrees the amount of memory
295 * specfied by pool_data
296 */
297void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data)
298{
299 size_t size = (size_t)(long)pool_data;
300 return kmalloc(size, gfp_mask);
301}
302EXPORT_SYMBOL(mempool_kmalloc);
303
304void *mempool_kzalloc(gfp_t gfp_mask, void *pool_data)
305{
306 size_t size = (size_t) pool_data;
307 return kzalloc(size, gfp_mask);
308}
309EXPORT_SYMBOL(mempool_kzalloc);
310
311void mempool_kfree(void *element, void *pool_data)
312{
313 kfree(element);
314}
315EXPORT_SYMBOL(mempool_kfree);
316
317/*
318 * A simple mempool-backed page allocator that allocates pages
319 * of the order specified by pool_data.
320 */
321void *mempool_alloc_pages(gfp_t gfp_mask, void *pool_data)
322{
323 int order = (int)(long)pool_data;
324 return alloc_pages(gfp_mask, order);
325}
326EXPORT_SYMBOL(mempool_alloc_pages);
327
328void mempool_free_pages(void *element, void *pool_data)
329{
330 int order = (int)(long)pool_data;
331 __free_pages(element, order);
332}
333EXPORT_SYMBOL(mempool_free_pages);