From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 14420A046B for ; Tue, 25 Jun 2019 18:05:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F096F1BA5B; Tue, 25 Jun 2019 18:05:45 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9FEA91B9FC for ; Tue, 25 Jun 2019 18:05:41 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2019 09:05:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,416,1557212400"; d="scan'208";a="336894680" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.125]) by orsmga005.jf.intel.com with ESMTP; 25 Jun 2019 09:05:28 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Bruce Richardson , david.marchand@redhat.com, thomas@monjalon.net, stephen@networkplumber.org Date: Tue, 25 Jun 2019 17:05:13 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 01/14] eal: add API to lock/unlock memory hotplug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. Create a new common file for all things mem config, and a new API namespace rte_mcfg_*. Signed-off-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_mcfg.c | 34 +++++++++++++++++++ .../common/include/rte_eal_memconfig.h | 24 +++++++++++++ lib/librte_eal/common/meson.build | 1 + lib/librte_eal/freebsd/eal/Makefile | 1 + lib/librte_eal/linux/eal/Makefile | 1 + lib/librte_eal/rte_eal_version.map | 4 +++ 6 files changed, 65 insertions(+) create mode 100644 lib/librte_eal/common/eal_common_mcfg.c diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c new file mode 100644 index 000000000..985d36cc2 --- /dev/null +++ b/lib/librte_eal/common/eal_common_mcfg.c @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Intel Corporation + */ + +#include +#include + +void +rte_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_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_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_mcfg_mem_write_unlock(void) +{ + struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock); +} diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h index 84aabe36c..a554518ef 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_mcfg_mem_read_lock(void); + +/** + * Unlock the internal EAL shared memory configuration for shared access. + */ +void +rte_mcfg_mem_read_unlock(void); + +/** + * Lock the internal EAL shared memory configuration for exclusive access. + */ +void +rte_mcfg_mem_write_lock(void); + +/** + * Unlock the internal EAL shared memory configuration for exclusive access. + */ +void +rte_mcfg_mem_write_unlock(void); + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build index 0670e4102..710168b29 100644 --- a/lib/librte_eal/common/meson.build +++ b/lib/librte_eal/common/meson.build @@ -18,6 +18,7 @@ common_sources = files( 'eal_common_launch.c', 'eal_common_lcore.c', 'eal_common_log.c', + 'eal_common_mcfg.c', 'eal_common_memalloc.c', 'eal_common_memory.c', 'eal_common_memzone.c', diff --git a/lib/librte_eal/freebsd/eal/Makefile b/lib/librte_eal/freebsd/eal/Makefile index 19854ee2c..dc56af582 100644 --- a/lib/librte_eal/freebsd/eal/Makefile +++ b/lib/librte_eal/freebsd/eal/Makefile @@ -44,6 +44,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_timer.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_memzone.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_log.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_launch.c +SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_mcfg.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_memalloc.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_memory.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_tailqs.c diff --git a/lib/librte_eal/linux/eal/Makefile b/lib/librte_eal/linux/eal/Makefile index 6e5261152..3b2642eb8 100644 --- a/lib/librte_eal/linux/eal/Makefile +++ b/lib/librte_eal/linux/eal/Makefile @@ -52,6 +52,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_timer.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_memzone.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_log.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_launch.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_mcfg.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_memalloc.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_memory.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_tailqs.c diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 824edf0ff..faad879db 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -292,6 +292,10 @@ DPDK_19.08 { rte_lcore_index; rte_lcore_to_socket_id; + rte_mcfg_mem_read_lock; + rte_mcfg_mem_read_unlock; + rte_mcfg_mem_write_lock; + rte_mcfg_mem_write_unlock; } DPDK_19.05; -- 2.17.1