[01/25] eal: add API to lock/unlock memory hotplug
Checks
Commit Message
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
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.
@@ -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)
{
@@ -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
@@ -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: