aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-02-01 06:28:41 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-03-13 18:38:13 -0400
commit0225bdfafd818f895fa4a4512f124a1614e011e2 (patch)
treebdc0b79b1d1731cd67e41f430b89833d2dd44bad /include/linux
parent737cd174d1666620f2c41a4552623125de6bd80d (diff)
downloadlinux-0225bdfafd818f895fa4a4512f124a1614e011e2.tar.gz
mempool: kvmalloc pool
Add mempool_init_kvmalloc_pool() and mempool_create_kvmalloc_pool(), which wrap kvmalloc() instead of kmalloc() - kmalloc() with a vmalloc() fallback. This is part of a bcachefs cleanup - dropping an internal kvpmalloc() helper (which predates kvmalloc()) along with mempool helpers; this replaces the bcachefs-private kvpmalloc_pool. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> Cc: linux-mm@kvack.org
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/mempool.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/mempool.h b/include/linux/mempool.h
index 7be1e32e6d421..16c5cc807ff6b 100644
--- a/include/linux/mempool.h
+++ b/include/linux/mempool.h
@@ -95,6 +95,19 @@ static inline mempool_t *mempool_create_kmalloc_pool(int min_nr, size_t size)
(void *) size);
}
+void *mempool_kvmalloc(gfp_t gfp_mask, void *pool_data);
+void mempool_kvfree(void *element, void *pool_data);
+
+static inline int mempool_init_kvmalloc_pool(mempool_t *pool, int min_nr, size_t size)
+{
+ return mempool_init(pool, min_nr, mempool_kvmalloc, mempool_kvfree, (void *) size);
+}
+
+static inline mempool_t *mempool_create_kvmalloc_pool(int min_nr, size_t size)
+{
+ return mempool_create(min_nr, mempool_kvmalloc, mempool_kvfree, (void *) size);
+}
+
/*
* A mempool_alloc_t and mempool_free_t for a simple page allocator that
* allocates pages of the order specified by pool_data