[01/25] eal: add API to lock/unlock memory hotplug

Message ID 6473125811ac8ed499079652b7f3c32907155fc9.1559147228.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Headers
Series Make shared memory config non-public |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation fail Compilation issues

Commit Message

Burakov, Anatoly May 29, 2019, 4:30 p.m. UTC
  Currently, the memory hotplug is locked automatically by all
memory-related _walk() functions, but sometimes locking the
memory subsystem outside of them is needed. There is no
public API to do that, so it creates a dependency on shared
memory config to be public. Fix this by introducing a new
API to lock/unlock the memory hotplug subsystem.

Signed-off-by: Anatoly Burakov <anatoly.burakov@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            | 10 +++++++
 3 files changed, 62 insertions(+)
  

Comments

Stephen Hemminger May 29, 2019, 4:41 p.m. UTC | #1
On Wed, 29 May 2019 17:30:47 +0100
Anatoly Burakov <anatoly.burakov@intel.com> wrote:

> +rte_eal_mcfg_mem_read_lock(void)
> +{
> +	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
> +	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
> +}
> +

We should also make eal configuration private but that is another battle.
  

Patch

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 5ae8d0124..3baa2f23a 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -682,6 +682,34 @@  rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)
 	return ret;
 }
 
+void
+rte_eal_mcfg_mem_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+}
+
+void
+rte_eal_mcfg_mem_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+}
+
+void
+rte_eal_mcfg_mem_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+}
+
+void
+rte_eal_mcfg_mem_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+}
+
 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 84aabe36c..ef7d4f81a 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -100,6 +100,30 @@  rte_eal_mcfg_wait_complete(struct rte_mem_config* mcfg)
 		rte_pause();
 }
 
+/**
+ * Lock the internal EAL shared memory configuration for shared access.
+ */
+void
+rte_eal_mcfg_mem_read_lock(void);
+
+/**
+ * Unlock the internal EAL shared memory configuration for shared access.
+ */
+void
+rte_eal_mcfg_mem_read_unlock(void);
+
+/**
+ * Lock the internal EAL shared memory configuration for exclusive access.
+ */
+void
+rte_eal_mcfg_mem_write_lock(void);
+
+/**
+ * Unlock the internal EAL shared memory configuration for exclusive access.
+ */
+void
+rte_eal_mcfg_mem_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 245493461..690176fbf 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -287,6 +287,16 @@  DPDK_19.05 {
 
 } DPDK_18.11;
 
+DPDK_19.08 {
+	global:
+
+	rte_eal_mcfg_mem_read_lock;
+	rte_eal_mcfg_mem_read_unlock;
+	rte_eal_mcfg_mem_write_lock;
+	rte_eal_mcfg_mem_write_unlock;
+
+} DPDK_19.05;
+
 EXPERIMENTAL {
 	global: