[dpdk-dev] [PATCH 09/25] eal: add EAL tailq list lock/unlock API

Anatoly Burakov anatoly.burakov at intel.com
Wed May 29 18:30:55 CEST 2019


Currently, locking/unlocking the TAILQ list requires direct
access to the shared memory config. Add an API to do the same.

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

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index db44078fd..e95fe484f 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -707,6 +707,34 @@ rte_eal_mcfg_mem_write_unlock(void)
 	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
 }
 
+void
+rte_eal_mcfg_tailq_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->qlock);
+}
+
+void
+rte_eal_mcfg_tailq_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->qlock);
+}
+
+void
+rte_eal_mcfg_tailq_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->qlock);
+}
+
+void
+rte_eal_mcfg_tailq_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->qlock);
+}
+
 int __rte_experimental
 rte_memseg_get_fd_thread_unsafe(const struct rte_memseg *ms)
 {
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index ef7d4f81a..5aeda92b9 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -124,6 +124,30 @@ rte_eal_mcfg_mem_write_lock(void);
 void
 rte_eal_mcfg_mem_write_unlock(void);
 
+/**
+ * Lock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_eal_mcfg_tailq_read_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_eal_mcfg_tailq_read_unlock(void);
+
+/**
+ * Lock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_eal_mcfg_tailq_write_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_eal_mcfg_tailq_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 690176fbf..fa85cff79 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -294,6 +294,10 @@ DPDK_19.08 {
 	rte_eal_mcfg_mem_read_unlock;
 	rte_eal_mcfg_mem_write_lock;
 	rte_eal_mcfg_mem_write_unlock;
+	rte_eal_mcfg_tailq_read_lock;
+	rte_eal_mcfg_tailq_read_unlock;
+	rte_eal_mcfg_tailq_write_lock;
+	rte_eal_mcfg_tailq_write_unlock;
 
 } DPDK_19.05;
 
-- 
2.17.1


More information about the dev mailing list