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 2E10FA045E for ; Wed, 29 May 2019 18:35:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F0E471BA4D; Wed, 29 May 2019 18:31:59 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 129F11B9DA for ; Wed, 29 May 2019 18:31:52 +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 fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 May 2019 09:31:52 -0700 X-ExtLoop1: 1 Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.125]) by orsmga005.jf.intel.com with ESMTP; 29 May 2019 09:31:51 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: stephen@networkplumber.org, thomas@monjalon.net, david.marchand@redhat.com Date: Wed, 29 May 2019 17:31:07 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 21/25] eal: add new API to lock/unlock mempool list 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, in order to lock access to the mempool list, a direct access to the shared memory structure is needed. Add an API to do the same. Signed-off-by: Anatoly Burakov --- 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 e95fe484f..c398e6f0b 100644 --- a/lib/librte_eal/common/eal_common_memory.c +++ b/lib/librte_eal/common/eal_common_memory.c @@ -735,6 +735,34 @@ rte_eal_mcfg_tailq_write_unlock(void) rte_rwlock_write_unlock(&mcfg->qlock); } +void +rte_eal_mcfg_mempool_read_lock(void) +{ + struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + rte_rwlock_read_lock(&mcfg->mplock); +} + +void +rte_eal_mcfg_mempool_read_unlock(void) +{ + struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + rte_rwlock_read_unlock(&mcfg->mplock); +} + +void +rte_eal_mcfg_mempool_write_lock(void) +{ + struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + rte_rwlock_write_lock(&mcfg->mplock); +} + +void +rte_eal_mcfg_mempool_write_unlock(void) +{ + struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + rte_rwlock_write_unlock(&mcfg->mplock); +} + 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 5aeda92b9..d0bd5836b 100644 --- a/lib/librte_eal/common/include/rte_eal_memconfig.h +++ b/lib/librte_eal/common/include/rte_eal_memconfig.h @@ -148,6 +148,30 @@ rte_eal_mcfg_tailq_write_lock(void); void rte_eal_mcfg_tailq_write_unlock(void); +/** + * Lock the internal EAL Mempool list for shared access. + */ +void +rte_eal_mcfg_mempool_read_lock(void); + +/** + * Unlock the internal EAL Mempool list for shared access. + */ +void +rte_eal_mcfg_mempool_read_unlock(void); + +/** + * Lock the internal EAL Mempool list for exclusive access. + */ +void +rte_eal_mcfg_mempool_write_lock(void); + +/** + * Unlock the internal EAL Mempool list for exclusive access. + */ +void +rte_eal_mcfg_mempool_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 fa85cff79..255e6e036 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_mempool_read_lock; + rte_eal_mcfg_mempool_read_unlock; + rte_eal_mcfg_mempool_write_lock; + rte_eal_mcfg_mempool_write_unlock; rte_eal_mcfg_tailq_read_lock; rte_eal_mcfg_tailq_read_unlock; rte_eal_mcfg_tailq_write_lock; -- 2.17.1