From a57daa6976d9e918a00a6ad0df8655bb44588ba7 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 28 Jun 2019 17:18:30 +0900 Subject: [PATCH] env: Add an API to lookup the memory pool created by the primary process Add spdk_mempool_lookup to lookup the memory pool created by the primary process. This will be utilized in SPDK multi process application future. Signed-off-by: Shuhei Matsumoto Change-Id: I90505b6566dfc93ef5957ef4c73b1a6438c30742 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459739 Tested-by: SPDK CI Jenkins Reviewed-by: Seth Howell Reviewed-by: Darek Stojaczyk Reviewed-by: Ben Walker --- CHANGELOG.md | 3 +++ include/spdk/env.h | 9 +++++++++ lib/env_dpdk/env.c | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ad6e28de..3612185d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,9 @@ The parameter `free_space` has been added to spdk_ring_enqueue() to wait when the ring is almost full and resume when there is enough space available in the ring. +A new API `spdk_mempool_lookup` has been added to lookup the memory pool created +by the primary process. + ## v19.04: ### nvme diff --git a/include/spdk/env.h b/include/spdk/env.h index 4f3bb9bea..19f260126 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -442,6 +442,15 @@ size_t spdk_mempool_count(const struct spdk_mempool *pool); uint32_t spdk_mempool_obj_iter(struct spdk_mempool *mp, spdk_mempool_obj_cb_t obj_cb, void *obj_cb_arg); +/** + * Lookup the memory pool identified by the given name. + * + * \param name Name of the memory pool. + * + * \return a pointer to the memory pool on success, or NULL on failure. + */ +struct spdk_mempool *spdk_mempool_lookup(const char *name); + /** * Get the number of dedicated CPU cores utilized by this env abstraction. * diff --git a/lib/env_dpdk/env.c b/lib/env_dpdk/env.c index dbd746dc8..e74f2ee4d 100644 --- a/lib/env_dpdk/env.c +++ b/lib/env_dpdk/env.c @@ -296,6 +296,12 @@ spdk_mempool_obj_iter(struct spdk_mempool *mp, spdk_mempool_obj_cb_t obj_cb, obj_cb_arg); } +struct spdk_mempool * +spdk_mempool_lookup(const char *name) +{ + return (struct spdk_mempool *)rte_mempool_lookup(name); +} + bool spdk_process_is_primary(void) {