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.bura...@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(+) 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: -- 2.17.1