[v2,06/14] eal: add new API to lock/unlock mempool list

Message ID 14054ee1cce8033e5f056d4ba7c698e18ee10857.1561478388.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Make shared memory config non-public |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail apply issues

Commit Message

Burakov, Anatoly June 25, 2019, 4:05 p.m. UTC
  Currently, in order to lock access to the mempool list, a direct
access to the shared memory structure is needed. Add an API to do
the same.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.c       | 28 +++++++++++++++++++
 .../common/include/rte_eal_memconfig.h        | 24 ++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  4 +++
 3 files changed, 56 insertions(+)
  

Patch

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 05167e4dc..ba2bc37b7 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -60,3 +60,31 @@  rte_mcfg_tailq_write_unlock(void)
 	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	rte_rwlock_write_unlock(&mcfg->qlock);
 }
+
+void
+rte_mcfg_mempool_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->mplock);
+}
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index 240fa150b..58dcbb96d 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -148,6 +148,30 @@  rte_mcfg_tailq_write_lock(void);
 void
 rte_mcfg_tailq_write_unlock(void);
 
+/**
+ * Lock the internal EAL Mempool list for shared access.
+ */
+void
+rte_mcfg_mempool_read_lock(void);
+
+/**
+ * Unlock the internal EAL Mempool list for shared access.
+ */
+void
+rte_mcfg_mempool_read_unlock(void);
+
+/**
+ * Lock the internal EAL Mempool list for exclusive access.
+ */
+void
+rte_mcfg_mempool_write_lock(void);
+
+/**
+ * Unlock the internal EAL Mempool list for exclusive access.
+ */
+void
+rte_mcfg_mempool_write_unlock(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index ebdcdf269..c28951f65 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -296,6 +296,10 @@  DPDK_19.08 {
 	rte_mcfg_mem_read_unlock;
 	rte_mcfg_mem_write_lock;
 	rte_mcfg_mem_write_unlock;
+	rte_mcfg_mempool_read_lock;
+	rte_mcfg_mempool_read_unlock;
+	rte_mcfg_mempool_write_lock;
+	rte_mcfg_mempool_write_unlock;
 	rte_mcfg_tailq_read_lock;
 	rte_mcfg_tailq_read_unlock;
 	rte_mcfg_tailq_write_lock;