DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/25] Make shared memory config non-public
@ 2019-05-29 16:30 Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 01/25] eal: add API to lock/unlock memory hotplug Anatoly Burakov
                   ` (40 more replies)
  0 siblings, 41 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand

This patchset removes the shared memory config from public
API, and replaces all usages of said config with new API
calls.

The patchset is mostly a search-and-replace job and should
be pretty easy to review. However, the changes to ENA
driver are of particular interest, because they're using
the shared memory config in a way that i find confusing.
I tried to implement the equivalent changes as well as
i could, but since the code doesn't make any sense to me,
i would really like to request help from ENA maintainers.

Everything else should be pretty straightforward.

Anatoly Burakov (25):
  eal: add API to lock/unlock memory hotplug
  bus/fslmc: use new memory locking API
  net/mlx4: use new memory locking API
  net/mlx5: use new memory locking API
  net/virtio: use new memory locking API
  mem: use new memory locking API
  malloc: use new memory locking API
  vfio: use new memory locking API
  eal: add EAL tailq list lock/unlock API
  acl: use new tailq locking API
  distributor: use new tailq locking API
  efd: use new tailq locking API
  eventdev: use new tailq locking API
  hash: use new tailq locking API
  lpm: use new tailq locking API
  member: use new tailq locking API
  mempool: use new tailq locking API
  reorder: use new tailq locking API
  ring: use new tailq locking API
  stack: use new tailq locking API
  eal: add new API to lock/unlock mempool list
  mempool: use new mempool list locking API
  eal: remove unused macros
  net/ena: fix direct access to shared memory config
  eal: hide shared memory config

 app/test/test_memzone.c                       |   1 +
 app/test/test_tailq.c                         |   1 +
 drivers/bus/fslmc/fslmc_vfio.c                |   8 +-
 drivers/bus/pci/linux/pci_vfio.c              |   1 +
 drivers/net/ena/ena_ethdev.c                  |  18 +--
 drivers/net/mlx4/mlx4_mr.c                    |  11 +-
 drivers/net/mlx5/mlx5_mr.c                    |  11 +-
 .../net/virtio/virtio_user/virtio_user_dev.c  |   7 +-
 lib/librte_acl/rte_acl.c                      |  20 +--
 lib/librte_distributor/rte_distributor.c      |   5 +-
 lib/librte_distributor/rte_distributor_v20.c  |   5 +-
 lib/librte_eal/common/eal_common_memory.c     | 128 +++++++++++++---
 lib/librte_eal/common/eal_common_memzone.c    |   1 +
 lib/librte_eal/common/eal_common_tailqs.c     |   1 +
 lib/librte_eal/common/eal_memcfg.h            |  75 +++++++++
 lib/librte_eal/common/include/rte_eal.h       |  10 --
 .../common/include/rte_eal_memconfig.h        | 143 ++++++++++--------
 lib/librte_eal/common/malloc_heap.c           |  16 +-
 lib/librte_eal/common/malloc_mp.c             |   1 +
 lib/librte_eal/common/rte_malloc.c            |  33 ++--
 lib/librte_eal/freebsd/eal/eal_memory.c       |   1 +
 lib/librte_eal/linux/eal/eal.c                |   1 +
 lib/librte_eal/linux/eal/eal_memalloc.c       |   1 +
 lib/librte_eal/linux/eal/eal_memory.c         |   1 +
 lib/librte_eal/linux/eal/eal_vfio.c           |  17 +--
 lib/librte_eal/rte_eal_version.map            |  18 +++
 lib/librte_efd/rte_efd.c                      |  15 +-
 lib/librte_eventdev/rte_event_ring.c          |  16 +-
 lib/librte_hash/rte_cuckoo_hash.c             |  17 ++-
 lib/librte_hash/rte_fbk_hash.c                |  15 +-
 lib/librte_kni/rte_kni.c                      |  16 +-
 lib/librte_lpm/rte_lpm.c                      |  25 +--
 lib/librte_lpm/rte_lpm6.c                     |  15 +-
 lib/librte_member/rte_member.c                |  17 ++-
 lib/librte_mempool/rte_mempool.c              |  27 ++--
 lib/librte_reorder/rte_reorder.c              |  15 +-
 lib/librte_ring/rte_ring.c                    |  19 +--
 lib/librte_stack/rte_stack.c                  |  18 +--
 38 files changed, 460 insertions(+), 290 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_memcfg.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 01/25] eal: add API to lock/unlock memory hotplug
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:41   ` Stephen Hemminger
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 02/25] bus/fslmc: use new memory locking API Anatoly Burakov
                   ` (39 subsequent siblings)
  40 siblings, 1 reply; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand

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(+)

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

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 02/25] bus/fslmc: use new memory locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 01/25] eal: add API to lock/unlock memory hotplug Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-06-03  6:41   ` Shreyansh Jain
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 03/25] net/mlx4: " Anatoly Burakov
                   ` (38 subsequent siblings)
  40 siblings, 1 reply; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: Hemant Agrawal, Shreyansh Jain, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/bus/fslmc/fslmc_vfio.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 1aae56fa9..bf9911f56 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -347,14 +347,12 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,
 int rte_fslmc_vfio_dmamap(void)
 {
 	int i = 0, ret;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 
 	/* Lock before parsing and registering callback to memory subsystem */
-	rte_rwlock_read_lock(mem_lock);
+	rte_eal_mcfg_mem_read_lock();
 
 	if (rte_memseg_walk(fslmc_dmamap_seg, &i) < 0) {
-		rte_rwlock_read_unlock(mem_lock);
+		rte_eal_mcfg_mem_read_unlock();
 		return -1;
 	}
 
@@ -378,7 +376,7 @@ int rte_fslmc_vfio_dmamap(void)
 	/* Existing segments have been mapped and memory callback for hotplug
 	 * has been installed.
 	 */
-	rte_rwlock_read_unlock(mem_lock);
+	rte_eal_mcfg_mem_read_unlock();
 
 	return 0;
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 03/25] net/mlx4: use new memory locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 01/25] eal: add API to lock/unlock memory hotplug Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 02/25] bus/fslmc: use new memory locking API Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 04/25] net/mlx5: " Anatoly Burakov
                   ` (37 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, Shahaf Shuler, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/net/mlx4/mlx4_mr.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
index 48d458ad4..636d241e3 100644
--- a/drivers/net/mlx4/mlx4_mr.c
+++ b/drivers/net/mlx4/mlx4_mr.c
@@ -593,7 +593,6 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		       uintptr_t addr)
 {
 	struct mlx4_priv *priv = dev->data->dev_private;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	const struct rte_memseg_list *msl;
 	const struct rte_memseg *ms;
 	struct mlx4_mr *mr = NULL;
@@ -696,7 +695,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	 * just single page. If not, go on with the big chunk atomically from
 	 * here.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 	data_re = data;
 	if (len > msl->page_sz &&
 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
@@ -714,7 +713,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		 */
 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
 		data.end = data.start + msl->page_sz;
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_eal_mcfg_mem_read_unlock();
 		mr_free(mr);
 		goto alloc_resources;
 	}
@@ -734,7 +733,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		DEBUG("port %u found MR for %p on final lookup, abort",
 		      dev->data->port_id, (void *)addr);
 		rte_rwlock_write_unlock(&priv->mr.rwlock);
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_eal_mcfg_mem_read_unlock();
 		/*
 		 * Must be unlocked before calling rte_free() because
 		 * mlx4_mr_mem_event_free_cb() can be called inside.
@@ -802,12 +801,12 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	/* Lookup can't fail. */
 	assert(entry->lkey != UINT32_MAX);
 	rte_rwlock_write_unlock(&priv->mr.rwlock);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 	return entry->lkey;
 err_mrlock:
 	rte_rwlock_write_unlock(&priv->mr.rwlock);
 err_memlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 err_nolock:
 	/*
 	 * In case of error, as this can be called in a datapath, a warning
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 04/25] net/mlx5: use new memory locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (2 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 03/25] net/mlx4: " Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 05/25] net/virtio: " Anatoly Burakov
                   ` (36 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: Shahaf Shuler, Yongseok Koh, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/net/mlx5/mlx5_mr.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 66e8e874e..43281ab93 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -580,7 +580,6 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_ibv_shared *sh = priv->sh;
 	struct mlx5_dev_config *config = &priv->config;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	const struct rte_memseg_list *msl;
 	const struct rte_memseg *ms;
 	struct mlx5_mr *mr = NULL;
@@ -684,7 +683,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	 * just single page. If not, go on with the big chunk atomically from
 	 * here.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 	data_re = data;
 	if (len > msl->page_sz &&
 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
@@ -702,7 +701,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 		 */
 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
 		data.end = data.start + msl->page_sz;
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_eal_mcfg_mem_read_unlock();
 		mr_free(mr);
 		goto alloc_resources;
 	}
@@ -722,7 +721,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 		DEBUG("port %u found MR for %p on final lookup, abort",
 		      dev->data->port_id, (void *)addr);
 		rte_rwlock_write_unlock(&sh->mr.rwlock);
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_eal_mcfg_mem_read_unlock();
 		/*
 		 * Must be unlocked before calling rte_free() because
 		 * mlx5_mr_mem_event_free_cb() can be called inside.
@@ -790,12 +789,12 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	/* Lookup can't fail. */
 	assert(entry->lkey != UINT32_MAX);
 	rte_rwlock_write_unlock(&sh->mr.rwlock);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 	return entry->lkey;
 err_mrlock:
 	rte_rwlock_write_unlock(&sh->mr.rwlock);
 err_memlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 err_nolock:
 	/*
 	 * In case of error, as this can be called in a datapath, a warning
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 05/25] net/virtio: use new memory locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (3 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 04/25] net/mlx5: " Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-30  6:39   ` Tiwei Bie
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 06/25] mem: " Anatoly Burakov
                   ` (35 subsequent siblings)
  40 siblings, 1 reply; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev
  Cc: Maxime Coquelin, Tiwei Bie, Zhihong Wang, stephen, thomas,
	david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index e743695e4..41ff19267 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -125,7 +125,6 @@ is_vhost_user_by_type(const char *path)
 int
 virtio_user_start_device(struct virtio_user_dev *dev)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	uint64_t features;
 	int ret;
 
@@ -142,7 +141,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 	 * replaced when we get proper supports from the
 	 * memory subsystem in the future.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 	pthread_mutex_lock(&dev->mutex);
 
 	if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0)
@@ -180,12 +179,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 
 	dev->started = true;
 	pthread_mutex_unlock(&dev->mutex);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 
 	return 0;
 error:
 	pthread_mutex_unlock(&dev->mutex);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 	/* TODO: free resource here or caller to check */
 	return -1;
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 06/25] mem: use new memory locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (4 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 05/25] net/virtio: " Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 07/25] malloc: " Anatoly Burakov
                   ` (34 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_memory.c | 43 ++++++++++-------------
 1 file changed, 18 insertions(+), 25 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 3baa2f23a..db44078fd 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -596,13 +596,12 @@ rte_memseg_contig_walk_thread_unsafe(rte_memseg_contig_walk_t func, void *arg)
 int __rte_experimental
 rte_memseg_contig_walk(rte_memseg_contig_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 	ret = rte_memseg_contig_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -638,13 +637,12 @@ rte_memseg_walk_thread_unsafe(rte_memseg_walk_t func, void *arg)
 int __rte_experimental
 rte_memseg_walk(rte_memseg_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 	ret = rte_memseg_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -671,13 +669,12 @@ rte_memseg_list_walk_thread_unsafe(rte_memseg_list_walk_t func, void *arg)
 int __rte_experimental
 rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 	ret = rte_memseg_list_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -755,12 +752,11 @@ rte_memseg_get_fd_thread_unsafe(const struct rte_memseg *ms)
 int __rte_experimental
 rte_memseg_get_fd(const struct rte_memseg *ms)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 	ret = rte_memseg_get_fd_thread_unsafe(ms);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -811,12 +807,11 @@ rte_memseg_get_fd_offset_thread_unsafe(const struct rte_memseg *ms,
 int __rte_experimental
 rte_memseg_get_fd_offset(const struct rte_memseg *ms, size_t *offset)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 	ret = rte_memseg_get_fd_offset_thread_unsafe(ms, offset);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -837,7 +832,7 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_lock();
 
 	/* make sure the segment doesn't already exist */
 	if (malloc_heap_find_external_seg(va_addr, len) != NULL) {
@@ -866,14 +861,13 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
 	/* memseg list successfully created - increment next socket ID */
 	mcfg->next_socket_id++;
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_unlock();
 	return ret;
 }
 
 int __rte_experimental
 rte_extmem_unregister(void *va_addr, size_t len)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct rte_memseg_list *msl;
 	int ret = 0;
 
@@ -881,7 +875,7 @@ rte_extmem_unregister(void *va_addr, size_t len)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_lock();
 
 	/* find our segment */
 	msl = malloc_heap_find_external_seg(va_addr, len);
@@ -893,14 +887,13 @@ rte_extmem_unregister(void *va_addr, size_t len)
 
 	ret = malloc_heap_destroy_external_seg(msl);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_unlock();
 	return ret;
 }
 
 static int
 sync_memory(void *va_addr, size_t len, bool attach)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct rte_memseg_list *msl;
 	int ret = 0;
 
@@ -908,7 +901,7 @@ sync_memory(void *va_addr, size_t len, bool attach)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_lock();
 
 	/* find our segment */
 	msl = malloc_heap_find_external_seg(va_addr, len);
@@ -923,7 +916,7 @@ sync_memory(void *va_addr, size_t len, bool attach)
 		ret = rte_fbarray_detach(&msl->memseg_arr);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_unlock();
 	return ret;
 }
 
@@ -951,7 +944,7 @@ rte_eal_memory_init(void)
 		return -1;
 
 	/* lock mem hotplug here, to prevent races while we init */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 
 	if (rte_eal_memseg_init() < 0)
 		goto fail;
@@ -970,6 +963,6 @@ rte_eal_memory_init(void)
 
 	return 0;
 fail:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 	return -1;
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 07/25] malloc: use new memory locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (5 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 06/25] mem: " Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 08/25] vfio: " Anatoly Burakov
                   ` (33 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/malloc_heap.c | 14 ++++++-------
 lib/librte_eal/common/rte_malloc.c  | 32 +++++++++++++----------------
 2 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index f9235932e..0298ec1ca 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -485,10 +485,9 @@ try_expand_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,
 		int socket, unsigned int flags, size_t align, size_t bound,
 		bool contig)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_lock();
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		ret = try_expand_heap_primary(heap, pg_sz, elt_size, socket,
@@ -498,7 +497,7 @@ try_expand_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,
 				flags, align, bound, contig);
 	}
 
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_unlock();
 	return ret;
 }
 
@@ -821,7 +820,6 @@ malloc_heap_free_pages(void *aligned_start, size_t aligned_len)
 int
 malloc_heap_free(struct malloc_elem *elem)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap;
 	void *start, *aligned_start, *end, *aligned_end;
 	size_t len, aligned_len, page_sz;
@@ -935,7 +933,7 @@ malloc_heap_free(struct malloc_elem *elem)
 
 	/* now we can finally free us some pages */
 
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_lock();
 
 	/*
 	 * we allow secondary processes to clear the heap of this allocated
@@ -990,7 +988,7 @@ malloc_heap_free(struct malloc_elem *elem)
 	RTE_LOG(DEBUG, EAL, "Heap on socket %d was shrunk by %zdMB\n",
 		msl->socket_id, aligned_len >> 20ULL);
 
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_unlock();
 free_unlock:
 	rte_spinlock_unlock(&(heap->lock));
 	return ret;
@@ -1344,7 +1342,7 @@ rte_eal_malloc_heap_init(void)
 
 	if (register_mp_requests()) {
 		RTE_LOG(ERR, EAL, "Couldn't register malloc multiprocess actions\n");
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_eal_mcfg_mem_read_unlock();
 		return -1;
 	}
 
@@ -1352,7 +1350,7 @@ rte_eal_malloc_heap_init(void)
 	 * even come before primary itself is fully initialized, and secondaries
 	 * do not need to initialize the heap.
 	 */
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 
 	/* secondary process does not need to initialize anything */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index 54792ea5b..4d83bf518 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -223,7 +223,7 @@ rte_malloc_heap_get_socket(const char *name)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 	for (idx = 0; idx < RTE_MAX_HEAPS; idx++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[idx];
 
@@ -239,7 +239,7 @@ rte_malloc_heap_get_socket(const char *name)
 		rte_errno = ENOENT;
 		ret = -1;
 	}
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -254,7 +254,7 @@ rte_malloc_heap_socket_is_external(int socket_id)
 	if (socket_id == SOCKET_ID_ANY)
 		return 0;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 	for (idx = 0; idx < RTE_MAX_HEAPS; idx++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[idx];
 
@@ -264,7 +264,7 @@ rte_malloc_heap_socket_is_external(int socket_id)
 			break;
 		}
 	}
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -352,7 +352,6 @@ int
 rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 		rte_iova_t iova_addrs[], unsigned int n_pages, size_t page_sz)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	unsigned int n;
@@ -369,7 +368,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_lock();
 
 	/* find our heap */
 	heap = find_named_heap(heap_name);
@@ -398,7 +397,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 	rte_spinlock_unlock(&heap->lock);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -406,7 +405,6 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 int
 rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	int ret;
@@ -418,7 +416,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_lock();
 	/* find our heap */
 	heap = find_named_heap(heap_name);
 	if (heap == NULL) {
@@ -448,7 +446,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 	ret = malloc_heap_destroy_external_seg(msl);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -456,7 +454,6 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 static int
 sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	int ret;
@@ -468,7 +465,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_lock();
 
 	/* find our heap */
 	heap = find_named_heap(heap_name);
@@ -516,7 +513,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 		}
 	}
 unlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_read_unlock();
 	return ret;
 }
 
@@ -549,7 +546,7 @@ rte_malloc_heap_create(const char *heap_name)
 	/* check if there is space in the heap list, or if heap with this name
 	 * already exists.
 	 */
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_lock();
 
 	for (i = 0; i < RTE_MAX_HEAPS; i++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[i];
@@ -578,7 +575,7 @@ rte_malloc_heap_create(const char *heap_name)
 	/* we're sure that we can create a new heap, so do it */
 	ret = malloc_heap_create(heap, heap_name);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -586,7 +583,6 @@ rte_malloc_heap_create(const char *heap_name)
 int
 rte_malloc_heap_destroy(const char *heap_name)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	int ret;
 
@@ -597,7 +593,7 @@ rte_malloc_heap_destroy(const char *heap_name)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_lock();
 
 	/* start from non-socket heaps */
 	heap = find_named_heap(heap_name);
@@ -621,7 +617,7 @@ rte_malloc_heap_destroy(const char *heap_name)
 	if (ret < 0)
 		rte_spinlock_unlock(&heap->lock);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_eal_mcfg_mem_write_unlock();
 
 	return ret;
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 08/25] vfio: use new memory locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (6 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 07/25] malloc: " Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 09/25] eal: add EAL tailq list lock/unlock API Anatoly Burakov
                   ` (32 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/linux/eal/eal_vfio.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index 6892a2c14..36f0d1ca7 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -635,8 +635,6 @@ int
 rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 		int *vfio_dev_fd, struct vfio_device_info *device_info)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 	struct vfio_group_status group_status = {
 			.argsz = sizeof(group_status)
 	};
@@ -739,7 +737,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 			/* lock memory hotplug before mapping and release it
 			 * after registering callback, to prevent races
 			 */
-			rte_rwlock_read_lock(mem_lock);
+			rte_eal_mcfg_mem_read_lock();
 			if (vfio_cfg == default_vfio_cfg)
 				ret = t->dma_map_func(vfio_container_fd);
 			else
@@ -750,7 +748,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 					dev_addr, errno, strerror(errno));
 				close(vfio_group_fd);
 				rte_vfio_clear_group(vfio_group_fd);
-				rte_rwlock_read_unlock(mem_lock);
+				rte_eal_mcfg_mem_read_unlock();
 				return -1;
 			}
 
@@ -781,7 +779,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 							map->len);
 					rte_spinlock_recursive_unlock(
 							&user_mem_maps->lock);
-					rte_rwlock_read_unlock(mem_lock);
+					rte_eal_mcfg_mem_read_unlock();
 					return -1;
 				}
 			}
@@ -795,7 +793,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 			else
 				ret = 0;
 			/* unlock memory hotplug */
-			rte_rwlock_read_unlock(mem_lock);
+			rte_eal_mcfg_mem_read_unlock();
 
 			if (ret && rte_errno != ENOTSUP) {
 				RTE_LOG(ERR, EAL, "Could not install memory event callback for VFIO\n");
@@ -862,8 +860,6 @@ int
 rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 		    int vfio_dev_fd)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 	struct vfio_group_status group_status = {
 			.argsz = sizeof(group_status)
 	};
@@ -876,7 +872,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 	 * VFIO device, because this might be the last device and we might need
 	 * to unregister the callback.
 	 */
-	rte_rwlock_read_lock(mem_lock);
+	rte_eal_mcfg_mem_read_lock();
 
 	/* get group number */
 	ret = rte_vfio_get_group_num(sysfs_base, dev_addr, &iommu_group_num);
@@ -947,7 +943,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 	ret = 0;
 
 out:
-	rte_rwlock_read_unlock(mem_lock);
+	rte_eal_mcfg_mem_read_unlock();
 	return ret;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 09/25] eal: add EAL tailq list lock/unlock API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (7 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 08/25] vfio: " Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 10/25] acl: use new tailq locking API Anatoly Burakov
                   ` (31 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand

Currently, locking/unlocking the TAILQ list requires direct
access to the shared memory config. Add an API to do the same.

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            |  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 db44078fd..e95fe484f 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -707,6 +707,34 @@ rte_eal_mcfg_mem_write_unlock(void)
 	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
 }
 
+void
+rte_eal_mcfg_tailq_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->qlock);
+}
+
+void
+rte_eal_mcfg_tailq_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->qlock);
+}
+
+void
+rte_eal_mcfg_tailq_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->qlock);
+}
+
+void
+rte_eal_mcfg_tailq_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->qlock);
+}
+
 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 ef7d4f81a..5aeda92b9 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -124,6 +124,30 @@ rte_eal_mcfg_mem_write_lock(void);
 void
 rte_eal_mcfg_mem_write_unlock(void);
 
+/**
+ * Lock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_eal_mcfg_tailq_read_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_eal_mcfg_tailq_read_unlock(void);
+
+/**
+ * Lock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_eal_mcfg_tailq_write_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_eal_mcfg_tailq_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 690176fbf..fa85cff79 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_tailq_read_lock;
+	rte_eal_mcfg_tailq_read_unlock;
+	rte_eal_mcfg_tailq_write_lock;
+	rte_eal_mcfg_tailq_write_unlock;
 
 } DPDK_19.05;
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 10/25] acl: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (8 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 09/25] eal: add EAL tailq list lock/unlock API Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 11/25] distributor: " Anatoly Burakov
                   ` (30 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_acl/rte_acl.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index c436a9bfd..82f3376a5 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -146,13 +146,13 @@ rte_acl_find_existing(const char *name)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, acl_list, next) {
 		ctx = (struct rte_acl_ctx *) te->data;
 		if (strncmp(name, ctx->name, sizeof(ctx->name)) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -172,7 +172,7 @@ rte_acl_free(struct rte_acl_ctx *ctx)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, acl_list, next) {
@@ -180,13 +180,13 @@ rte_acl_free(struct rte_acl_ctx *ctx)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(acl_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_free(ctx->mem);
 	rte_free(ctx);
@@ -216,7 +216,7 @@ rte_acl_create(const struct rte_acl_param *param)
 	sz = sizeof(*ctx) + param->max_rule_num * param->rule_size;
 
 	/* get EAL TAILQ lock. */
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* if we already have one with that name */
 	TAILQ_FOREACH(te, acl_list, next) {
@@ -258,7 +258,7 @@ rte_acl_create(const struct rte_acl_param *param)
 	}
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 	return ctx;
 }
 
@@ -367,10 +367,10 @@ rte_acl_list_dump(void)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, acl_list, next) {
 		ctx = (struct rte_acl_ctx *) te->data;
 		rte_acl_dump(ctx);
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 11/25] distributor: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (9 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 10/25] acl: use new tailq locking API Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 12/25] efd: " Anatoly Burakov
                   ` (29 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: David Hunt, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_distributor/rte_distributor.c     | 4 ++--
 lib/librte_distributor/rte_distributor_v20.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 208abfb1d..7e2892554 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -645,9 +645,9 @@ rte_distributor_create_v1705(const char *name,
 					  rte_dist_burst_list);
 
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(dist_burst_list, d, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return d;
 }
diff --git a/lib/librte_distributor/rte_distributor_v20.c b/lib/librte_distributor/rte_distributor_v20.c
index cd5940713..beec9c051 100644
--- a/lib/librte_distributor/rte_distributor_v20.c
+++ b/lib/librte_distributor/rte_distributor_v20.c
@@ -392,9 +392,9 @@ rte_distributor_create_v20(const char *name,
 	distributor_list = RTE_TAILQ_CAST(rte_distributor_tailq.head,
 					  rte_distributor_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(distributor_list, d, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return d;
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 12/25] efd: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (10 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 11/25] distributor: " Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 13/25] eventdev: " Anatoly Burakov
                   ` (28 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: Byron Marohn, Pablo de Lara Guarch, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_efd/rte_efd.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index 14e493bc3..71f067df6 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -532,7 +532,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	num_chunks_shift = rte_bsf32(num_chunks);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/*
 	 * Guarantee there's no existing: this is normally already checked
@@ -685,7 +685,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	te->data = (void *) table;
 	TAILQ_INSERT_TAIL(efd_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	snprintf(ring_name, sizeof(ring_name), "HT_%s", table->name);
 	/* Create ring (Dummy slot index is not enqueued) */
@@ -705,7 +705,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	return table;
 
 error_unlock_exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 	rte_efd_free(table);
 
 	return NULL;
@@ -720,7 +720,7 @@ rte_efd_find_existing(const char *name)
 
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, efd_list, next)
 	{
@@ -728,7 +728,7 @@ rte_efd_find_existing(const char *name)
 		if (strncmp(name, table->name, RTE_EFD_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -751,7 +751,7 @@ rte_efd_free(struct rte_efd_table *table)
 		rte_free(table->chunks[socket_id]);
 
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH_SAFE(te, efd_list, next, temp) {
 		if (te->data == (void *) table) {
@@ -761,7 +761,7 @@ rte_efd_free(struct rte_efd_table *table)
 		}
 	}
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 	rte_ring_free(table->free_slots);
 	rte_free(table->offline_chunks);
 	rte_free(table->keys);
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 13/25] eventdev: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (11 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 12/25] efd: " Anatoly Burakov
@ 2019-05-29 16:30 ` Anatoly Burakov
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 14/25] hash: " Anatoly Burakov
                   ` (27 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:30 UTC (permalink / raw)
  To: dev; +Cc: Jerin Jacob, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eventdev/rte_event_ring.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/librte_eventdev/rte_event_ring.c b/lib/librte_eventdev/rte_event_ring.c
index 16d02a953..fcb90eb45 100644
--- a/lib/librte_eventdev/rte_event_ring.c
+++ b/lib/librte_eventdev/rte_event_ring.c
@@ -72,7 +72,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/*
 	 * reserve a memory zone for this ring. If we can't get rte_config or
@@ -89,7 +89,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 			if (rte_memzone_free(mz) != 0)
 				RTE_LOG(ERR, RING, "Cannot free memzone\n");
 			rte_free(te);
-			rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+			rte_eal_mcfg_tailq_write_unlock();
 			return NULL;
 		}
 
@@ -102,7 +102,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return r;
 }
@@ -118,7 +118,7 @@ rte_event_ring_lookup(const char *name)
 	ring_list = RTE_TAILQ_CAST(rte_event_ring_tailq.head,
 			rte_event_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		r = (struct rte_event_ring *) te->data;
@@ -126,7 +126,7 @@ rte_event_ring_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -163,7 +163,7 @@ rte_event_ring_free(struct rte_event_ring *r)
 
 	ring_list = RTE_TAILQ_CAST(rte_event_ring_tailq.head,
 			rte_event_ring_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, ring_list, next) {
@@ -172,13 +172,13 @@ rte_event_ring_free(struct rte_event_ring *r)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(ring_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 14/25] hash: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (12 preceding siblings ...)
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 13/25] eventdev: " Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 15/25] lpm: " Anatoly Burakov
                   ` (26 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev
  Cc: Yipeng Wang, Sameh Gobriel, Bruce Richardson, Pablo de Lara,
	Ferruh Yigit, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 16 ++++++++--------
 lib/librte_hash/rte_fbk_hash.c    | 14 +++++++-------
 lib/librte_kni/rte_kni.c          | 16 ++++++++--------
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 2dc423fba..ffe649411 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -52,13 +52,13 @@ rte_hash_find_existing(const char *name)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, hash_list, next) {
 		h = (struct rte_hash *) te->data;
 		if (strncmp(name, h->name, RTE_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -239,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	snprintf(hash_name, sizeof(hash_name), "HT_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing: this is normally already checked
 	 * by ring creation above */
@@ -437,11 +437,11 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	te->data = (void *) h;
 	TAILQ_INSERT_TAIL(hash_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return h;
 err_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 err:
 	rte_ring_free(r);
 	rte_ring_free(r_ext);
@@ -466,7 +466,7 @@ rte_hash_free(struct rte_hash *h)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, hash_list, next) {
@@ -475,13 +475,13 @@ rte_hash_free(struct rte_hash *h)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	if (h->use_local_cache)
 		rte_free(h->local_free_slots);
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index 9360f7981..54a8596ab 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -50,13 +50,13 @@ rte_fbk_hash_find_existing(const char *name)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
 		h = (struct rte_fbk_hash_table *) te->data;
 		if (strncmp(name, h->name, RTE_FBK_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 	if (te == NULL) {
 		rte_errno = ENOENT;
 		return NULL;
@@ -103,7 +103,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 
 	snprintf(hash_name, sizeof(hash_name), "FBK_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -165,7 +165,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 	TAILQ_INSERT_TAIL(fbk_hash_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return ht;
 }
@@ -188,7 +188,7 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -197,13 +197,13 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(fbk_hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_free(ht);
 	rte_free(te);
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index e6507b07d..d0884aeb9 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -214,7 +214,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	kni = __rte_kni_get(conf->name);
 	if (kni != NULL) {
@@ -313,7 +313,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 	TAILQ_INSERT_TAIL(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	/* Allocate mbufs and then put them into alloc_q */
 	kni_allocate_mbufs(kni);
@@ -327,7 +327,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 kni_fail:
 	rte_free(te);
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return NULL;
 }
@@ -390,7 +390,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, kni_list, next) {
 		if (te->data == kni)
@@ -408,7 +408,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	TAILQ_REMOVE(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	/* mbufs in all fifo should be released, except request/response */
 
@@ -432,7 +432,7 @@ rte_kni_release(struct rte_kni *kni)
 	return 0;
 
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return -1;
 }
@@ -649,11 +649,11 @@ rte_kni_get(const char *name)
 	if (name == NULL || name[0] == '\0')
 		return NULL;
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 
 	kni = __rte_kni_get(name);
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	return kni;
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 15/25] lpm: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (13 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 14/25] hash: " Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 16/25] member: " Anatoly Burakov
                   ` (25 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Vladimir Medvedkin, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_lpm/rte_lpm.c  | 24 ++++++++++++------------
 lib/librte_lpm/rte_lpm6.c | 14 +++++++-------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index 6b7b28a2e..bb1c5b197 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -97,13 +97,13 @@ rte_lpm_find_existing_v20(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -123,13 +123,13 @@ rte_lpm_find_existing_v1604(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -170,7 +170,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	/* Determine the amount of memory to allocate. */
 	mem_size = sizeof(*lpm) + (sizeof(lpm->rules_tbl[0]) * max_rules);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -212,7 +212,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return lpm;
 }
@@ -247,7 +247,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	tbl8s_size = (sizeof(struct rte_lpm_tbl_entry) *
 			RTE_LPM_TBL8_GROUP_NUM_ENTRIES * config->number_tbl8s);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -315,7 +315,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return lpm;
 }
@@ -339,7 +339,7 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -349,7 +349,7 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_free(lpm);
 	rte_free(te);
@@ -368,7 +368,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -378,7 +378,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_free(lpm->tbl8);
 	rte_free(lpm->rules_tbl);
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index a91803113..5fabfa3d4 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -316,7 +316,7 @@ rte_lpm6_create(const char *name, int socket_id,
 	mem_size = sizeof(*lpm) + (sizeof(lpm->tbl8[0]) *
 			RTE_LPM6_TBL8_GROUP_NUM_ENTRIES * config->number_tbl8s);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* Guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -363,11 +363,11 @@ rte_lpm6_create(const char *name, int socket_id,
 	te->data = (void *) lpm;
 
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 	return lpm;
 
 fail:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 fail_wo_unlock:
 	rte_free(tbl8_hdrs);
@@ -389,13 +389,13 @@ rte_lpm6_find_existing(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = (struct rte_lpm6 *) te->data;
 		if (strncmp(name, l->name, RTE_LPM6_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -420,7 +420,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -431,7 +431,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_free(lpm->tbl8_hdrs);
 	rte_free(lpm->tbl8_pool);
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 16/25] member: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (14 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 15/25] lpm: " Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 17/25] mempool: " Anatoly Burakov
                   ` (24 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev; +Cc: Yipeng Wang, Sameh Gobriel, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_member/rte_member.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index fd228f4ba..70322d86a 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -32,13 +32,13 @@ rte_member_find_existing(const char *name)
 
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, member_list, next) {
 		setsum = (struct rte_member_setsum *) te->data;
 		if (strncmp(name, setsum->name, RTE_MEMBER_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -56,17 +56,17 @@ rte_member_free(struct rte_member_setsum *setsum)
 	if (setsum == NULL)
 		return;
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 	TAILQ_FOREACH(te, member_list, next) {
 		if (te->data == (void *)setsum)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		return;
 	}
 	TAILQ_REMOVE(member_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	switch (setsum->type) {
 	case RTE_MEMBER_TYPE_HT:
@@ -105,7 +105,7 @@ rte_member_create(const struct rte_member_parameters *params)
 
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, member_list, next) {
 		setsum = te->data;
@@ -159,13 +159,13 @@ rte_member_create(const struct rte_member_parameters *params)
 
 	te->data = (void *)setsum;
 	TAILQ_INSERT_TAIL(member_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 	return setsum;
 
 error_unlock_exit:
 	rte_free(te);
 	rte_free(setsum);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 	return NULL;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 17/25] mempool: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (15 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 16/25] member: " Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 16:47   ` Andrew Rybchenko
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 18/25] reorder: " Anatoly Burakov
                   ` (23 subsequent siblings)
  40 siblings, 1 reply; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, Andrew Rybchenko, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_mempool/rte_mempool.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 69bd2a65c..aacfdafdd 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -711,7 +711,7 @@ rte_mempool_free(struct rte_mempool *mp)
 		return;
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, mempool_list, next) {
 		if (te->data == (void *)mp)
@@ -722,7 +722,7 @@ rte_mempool_free(struct rte_mempool *mp)
 		TAILQ_REMOVE(mempool_list, te, next);
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_mempool_free_memchunks(mp);
 	rte_mempool_ops_free(mp);
@@ -898,9 +898,9 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 
 	te->data = mp;
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(mempool_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
 
 	return mp;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 18/25] reorder: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (16 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 17/25] mempool: " Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 19/25] ring: " Anatoly Burakov
                   ` (22 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev; +Cc: Reshma Pattan, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_reorder/rte_reorder.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index 3a4a1b0a0..c505a4810 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -119,7 +119,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, reorder_list, next) {
@@ -152,7 +152,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 	}
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 	return b;
 }
 
@@ -193,7 +193,7 @@ rte_reorder_free(struct rte_reorder_buffer *b)
 
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, reorder_list, next) {
@@ -201,13 +201,13 @@ rte_reorder_free(struct rte_reorder_buffer *b)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(reorder_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_reorder_free_mbufs(b);
 
@@ -229,13 +229,13 @@ rte_reorder_find_existing(const char *name)
 
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, reorder_list, next) {
 		b = (struct rte_reorder_buffer *) te->data;
 		if (strncmp(name, b->name, RTE_REORDER_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 19/25] ring: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (17 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 18/25] reorder: " Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 20/25] stack: " Anatoly Burakov
                   ` (21 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_ring/rte_ring.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index b89ecf999..8d0744153 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -147,7 +147,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* reserve a memory zone for this ring. If we can't get rte_config or
 	 * we are secondary process, the memzone_reserve function will set
@@ -169,7 +169,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
 		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return r;
 }
@@ -200,7 +200,7 @@ rte_ring_free(struct rte_ring *r)
 	}
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, ring_list, next) {
@@ -209,13 +209,13 @@ rte_ring_free(struct rte_ring *r)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(ring_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 }
@@ -245,13 +245,13 @@ rte_ring_list_dump(FILE *f)
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		rte_ring_dump(f, (struct rte_ring *) te->data);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 }
 
 /* search a ring from its name */
@@ -264,7 +264,7 @@ rte_ring_lookup(const char *name)
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		r = (struct rte_ring *) te->data;
@@ -272,7 +272,7 @@ rte_ring_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 20/25] stack: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (18 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 19/25] ring: " Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 18:20   ` Eads, Gage
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 21/25] eal: add new API to lock/unlock mempool list Anatoly Burakov
                   ` (20 subsequent siblings)
  40 siblings, 1 reply; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev; +Cc: Gage Eads, Olivier Matz, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_stack/rte_stack.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index 60f63a65b..a2671a7b8 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -84,13 +84,13 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	mz = rte_memzone_reserve_aligned(mz_name, sz, socket_id,
 					 0, __alignof__(*s));
 	if (mz == NULL) {
 		STACK_LOG_ERR("Cannot reserve stack memzone!\n");
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		rte_free(te);
 		return NULL;
 	}
@@ -102,7 +102,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 	/* Store the name for later lookups */
 	ret = strlcpy(s->name, name, sizeof(s->name));
 	if (ret < 0 || ret >= (int)sizeof(s->name)) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 
 		rte_errno = ENAMETOOLONG;
 		rte_free(te);
@@ -120,7 +120,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 
 	TAILQ_INSERT_TAIL(stack_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	return s;
 }
@@ -135,7 +135,7 @@ rte_stack_free(struct rte_stack *s)
 		return;
 
 	stack_list = RTE_TAILQ_CAST(rte_stack_tailq.head, rte_stack_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, stack_list, next) {
@@ -144,13 +144,13 @@ rte_stack_free(struct rte_stack *s)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_eal_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(stack_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 
@@ -171,7 +171,7 @@ rte_stack_lookup(const char *name)
 
 	stack_list = RTE_TAILQ_CAST(rte_stack_tailq.head, rte_stack_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, stack_list, next) {
 		r = (struct rte_stack *) te->data;
@@ -179,7 +179,7 @@ rte_stack_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_eal_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 21/25] eal: add new API to lock/unlock mempool list
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (19 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 20/25] stack: " Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 22/25] mempool: use new mempool list locking API Anatoly Burakov
                   ` (19 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand

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 <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            |  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

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 22/25] mempool: use new mempool list locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (20 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 21/25] eal: add new API to lock/unlock mempool list Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 16:50   ` Andrew Rybchenko
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 23/25] eal: remove unused macros Anatoly Burakov
                   ` (18 subsequent siblings)
  40 siblings, 1 reply; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, Andrew Rybchenko, stephen, thomas, david.marchand

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_mempool/rte_mempool.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index aacfdafdd..c98233828 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -830,7 +830,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_eal_mcfg_mempool_write_lock();
 
 	/*
 	 * reserve a memory zone for this mempool: private data is
@@ -901,12 +901,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	rte_eal_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(mempool_list, te, next);
 	rte_eal_mcfg_tailq_write_unlock();
-	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_eal_mcfg_mempool_write_unlock();
 
 	return mp;
 
 exit_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_eal_mcfg_mempool_write_unlock();
 	rte_free(te);
 	rte_mempool_free(mp);
 	return NULL;
@@ -1268,14 +1268,14 @@ rte_mempool_list_dump(FILE *f)
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_eal_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH(te, mempool_list, next) {
 		mp = (struct rte_mempool *) te->data;
 		rte_mempool_dump(f, mp);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_eal_mcfg_mempool_read_unlock();
 }
 
 /* search a mempool from its name */
@@ -1288,7 +1288,7 @@ rte_mempool_lookup(const char *name)
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_eal_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH(te, mempool_list, next) {
 		mp = (struct rte_mempool *) te->data;
@@ -1296,7 +1296,7 @@ rte_mempool_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_eal_mcfg_mempool_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -1315,11 +1315,11 @@ void rte_mempool_walk(void (*func)(struct rte_mempool *, void *),
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_eal_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH_SAFE(te, mempool_list, next, tmp_te) {
 		(*func)((struct rte_mempool *) te->data, arg);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_eal_mcfg_mempool_read_unlock();
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 23/25] eal: remove unused macros
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (21 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 22/25] mempool: use new mempool list locking API Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 24/25] net/ena: fix direct access to shared memory config Anatoly Burakov
                   ` (17 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand

These macros are not used anymore and can be removed.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/include/rte_eal.h | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index 73754aaf2..a93ad1379 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -437,16 +437,6 @@ typedef void	(*rte_usage_hook_t)(const char * prgname);
 rte_usage_hook_t
 rte_set_application_usage_hook(rte_usage_hook_t usage_func);
 
-/**
- * macro to get the lock of tailq in mem_config
- */
-#define RTE_EAL_TAILQ_RWLOCK         (&rte_eal_get_configuration()->mem_config->qlock)
-
-/**
- * macro to get the multiple lock of mempool shared by multiple-instance
- */
-#define RTE_EAL_MEMPOOL_RWLOCK            (&rte_eal_get_configuration()->mem_config->mplock)
-
 /**
  * Whether EAL is using huge pages (disabled by --no-huge option).
  * The no-huge mode cannot be used with UIO poll-mode drivers like igb/ixgbe.
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 24/25] net/ena: fix direct access to shared memory config
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (22 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 23/25] eal: remove unused macros Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-06-03  7:33   ` Michał Krawczyk
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 25/25] eal: hide " Anatoly Burakov
                   ` (16 subsequent siblings)
  40 siblings, 1 reply; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev
  Cc: Marcin Wojtas, Michal Krawczyk, Guy Tzalik, Evgeny Schemeilin,
	stephen, thomas, david.marchand

The ENA driver calculates a ring's NUMA node affinity by directly
accessing the memzone list. Fix it to do it through the public
API's instead.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/net/ena/ena_ethdev.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index b6651fc0f..e745e9e92 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -274,20 +274,6 @@ static const struct eth_dev_ops ena_dev_ops = {
 
 #define NUMA_NO_NODE	SOCKET_ID_ANY
 
-static inline int ena_cpu_to_node(int cpu)
-{
-	struct rte_config *config = rte_eal_get_configuration();
-	struct rte_fbarray *arr = &config->mem_config->memzones;
-	const struct rte_memzone *mz;
-
-	if (unlikely(cpu >= RTE_MAX_MEMZONE))
-		return NUMA_NO_NODE;
-
-	mz = rte_fbarray_get(arr, cpu);
-
-	return mz->socket_id;
-}
-
 static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
 				       struct ena_com_rx_ctx *ena_rx_ctx)
 {
@@ -1099,6 +1085,7 @@ static int ena_create_io_queue(struct ena_ring *ring)
 {
 	struct ena_adapter *adapter;
 	struct ena_com_dev *ena_dev;
+	struct rte_memseg_list *msl;
 	struct ena_com_create_io_ctx ctx =
 		/* policy set to _HOST just to satisfy icc compiler */
 		{ ENA_ADMIN_PLACEMENT_POLICY_HOST,
@@ -1126,7 +1113,8 @@ static int ena_create_io_queue(struct ena_ring *ring)
 	}
 	ctx.qid = ena_qid;
 	ctx.msix_vector = -1; /* interrupts not used */
-	ctx.numa_node = ena_cpu_to_node(ring->id);
+	msl = rte_mem_virt2memseg_list(ring);
+	ctx.numa_node = msl->socket_id;
 
 	rc = ena_com_create_io_queue(ena_dev, &ctx);
 	if (rc) {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH 25/25] eal: hide shared memory config
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (23 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 24/25] net/ena: fix direct access to shared memory config Anatoly Burakov
@ 2019-05-29 16:31 ` Anatoly Burakov
  2019-05-29 16:40   ` Stephen Hemminger
  2019-05-29 20:14   ` David Marchand
  2019-05-29 20:11 ` [dpdk-dev] [PATCH 00/25] Make shared memory config non-public David Marchand
                   ` (15 subsequent siblings)
  40 siblings, 2 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-05-29 16:31 UTC (permalink / raw)
  To: dev
  Cc: Konstantin Ananyev, David Hunt, Bruce Richardson, Byron Marohn,
	Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Reshma Pattan, stephen, thomas, david.marchand

Now that everything that has ever accessed the shared memory
config is doing so through the public API's, we can make it
internal. Since we're removing quite a few headers from
rte_eal_memconfig.h, we need to add them back in places
where this header is used.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 app/test/test_memzone.c                       |  1 +
 app/test/test_tailq.c                         |  1 +
 drivers/bus/pci/linux/pci_vfio.c              |  1 +
 lib/librte_acl/rte_acl.c                      |  2 +
 lib/librte_distributor/rte_distributor.c      |  1 +
 lib/librte_distributor/rte_distributor_v20.c  |  1 +
 lib/librte_eal/common/eal_common_memory.c     |  1 +
 lib/librte_eal/common/eal_common_memzone.c    |  1 +
 lib/librte_eal/common/eal_common_tailqs.c     |  1 +
 lib/librte_eal/common/eal_memcfg.h            | 75 +++++++++++++++++++
 .../common/include/rte_eal_memconfig.h        | 75 ++-----------------
 lib/librte_eal/common/malloc_heap.c           |  2 +
 lib/librte_eal/common/malloc_mp.c             |  1 +
 lib/librte_eal/common/rte_malloc.c            |  1 +
 lib/librte_eal/freebsd/eal/eal_memory.c       |  1 +
 lib/librte_eal/linux/eal/eal.c                |  1 +
 lib/librte_eal/linux/eal/eal_memalloc.c       |  1 +
 lib/librte_eal/linux/eal/eal_memory.c         |  1 +
 lib/librte_eal/linux/eal/eal_vfio.c           |  1 +
 lib/librte_efd/rte_efd.c                      |  1 +
 lib/librte_hash/rte_cuckoo_hash.c             |  1 +
 lib/librte_hash/rte_fbk_hash.c                |  1 +
 lib/librte_lpm/rte_lpm.c                      |  1 +
 lib/librte_lpm/rte_lpm6.c                     |  1 +
 lib/librte_member/rte_member.c                |  1 +
 lib/librte_mempool/rte_mempool.c              |  1 +
 lib/librte_reorder/rte_reorder.c              |  1 +
 lib/librte_ring/rte_ring.c                    |  1 +
 28 files changed, 109 insertions(+), 69 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_memcfg.h

diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index 9fe465e62..7501b63c5 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -19,6 +19,7 @@
 #include <rte_errno.h>
 #include <rte_malloc.h>
 #include "../../lib/librte_eal/common/malloc_elem.h"
+#include "../../lib/librte_eal/common/eal_memcfg.h"
 
 #include "test.h"
 
diff --git a/app/test/test_tailq.c b/app/test/test_tailq.c
index a4ecea2d8..7c9b69fdb 100644
--- a/app/test/test_tailq.c
+++ b/app/test/test_tailq.c
@@ -12,6 +12,7 @@
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
 #include <rte_string_fns.h>
+#include <rte_tailq.h>
 
 #include "test.h"
 
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index ebf6ccd3c..1ceb1c07b 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -20,6 +20,7 @@
 #include <rte_eal.h>
 #include <rte_bus.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "eal_filesystem.h"
 
diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index 82f3376a5..3f5437c69 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -4,6 +4,8 @@
 
 #include <rte_string_fns.h>
 #include <rte_acl.h>
+#include <rte_tailq.h>
+
 #include "acl.h"
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 7e2892554..39ac5a9f9 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -14,6 +14,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_private.h"
 #include "rte_distributor.h"
diff --git a/lib/librte_distributor/rte_distributor_v20.c b/lib/librte_distributor/rte_distributor_v20.c
index beec9c051..1c3fa8634 100644
--- a/lib/librte_distributor/rte_distributor_v20.c
+++ b/lib/librte_distributor/rte_distributor_v20.c
@@ -13,6 +13,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_v20.h"
 #include "rte_distributor_private.h"
diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index c398e6f0b..209206334 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -24,6 +24,7 @@
 #include "eal_memalloc.h"
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
+#include "eal_memcfg.h"
 #include "malloc_heap.h"
 
 /*
diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
index 521ad7ca1..ef6c909cb 100644
--- a/lib/librte_eal/common/eal_common_memzone.c
+++ b/lib/librte_eal/common/eal_common_memzone.c
@@ -24,6 +24,7 @@
 #include "malloc_heap.h"
 #include "malloc_elem.h"
 #include "eal_private.h"
+#include "eal_memcfg.h"
 
 static inline const struct rte_memzone *
 memzone_lookup_thread_unsafe(const char *name)
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index ca2a7d32a..b65819b07 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -23,6 +23,7 @@
 #include <rte_debug.h>
 
 #include "eal_private.h"
+#include "eal_memcfg.h"
 
 TAILQ_HEAD(rte_tailq_elem_head, rte_tailq_elem);
 /* local tailq list */
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
new file mode 100644
index 000000000..75891e6cb
--- /dev/null
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -0,0 +1,75 @@
+#ifndef EAL_MEMCFG_H
+#define EAL_MEMCFG_H
+
+#include <rte_config.h>
+#include <rte_eal_memconfig.h>
+#include <rte_malloc_heap.h>
+#include <rte_memory.h>
+#include <rte_memzone.h>
+#include <rte_pause.h>
+#include <rte_rwlock.h>
+#include <rte_tailq.h>
+
+/**
+ * the structure for the memory configuration for the RTE.
+ * Used by the rte_config structure. It is separated out, as for multi-process
+ * support, the memory details should be shared across instances
+ */
+struct rte_mem_config {
+	volatile uint32_t magic;   /**< Magic number - Sanity check. */
+
+	/* memory topology */
+	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
+	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
+
+	/**
+	 * current lock nest order
+	 *  - qlock->mlock (ring/hash/lpm)
+	 *  - mplock->qlock->mlock (mempool)
+	 * Notice:
+	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
+	 */
+	rte_rwlock_t mlock;   /**< only used by memzone LIB for thread-safe. */
+	rte_rwlock_t qlock;   /**< used for tailq operation for thread safe. */
+	rte_rwlock_t mplock;  /**< only used by mempool LIB for thread-safe. */
+
+	rte_rwlock_t memory_hotplug_lock;
+	/**< indicates whether memory hotplug request is in progress. */
+
+	/* memory segments and zones */
+	struct rte_fbarray memzones; /**< Memzone descriptors. */
+
+	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
+	/**< list of dynamic arrays holding memsegs */
+
+	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ];
+	/**< Tailqs for objects */
+
+	/* Heaps of Malloc */
+	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
+
+	/* next socket ID for external malloc heap */
+	int next_socket_id;
+
+	/* address of mem_config in primary process. used to map shared config
+	 * into exact same address the primary process maps it.
+	 */
+	uint64_t mem_cfg_addr;
+
+	/* legacy mem and single file segments options are shared */
+	uint32_t legacy_mem;
+	uint32_t single_file_segments;
+
+	/* keeps the more restricted dma mask */
+	uint8_t dma_maskbits;
+} __attribute__((packed));
+
+static inline void
+rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
+{
+	/* wait until shared mem_config finish initialising */
+	while (mcfg->magic != RTE_MAGIC)
+		rte_pause();
+}
+
+#endif // EAL_MEMCFG_H
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index d0bd5836b..776d30dc0 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -5,13 +5,12 @@
 #ifndef _RTE_EAL_MEMCONFIG_H_
 #define _RTE_EAL_MEMCONFIG_H_
 
-#include <rte_config.h>
-#include <rte_tailq.h>
-#include <rte_memory.h>
-#include <rte_memzone.h>
-#include <rte_malloc_heap.h>
-#include <rte_rwlock.h>
-#include <rte_pause.h>
+/**
+ * @file
+ *
+ * This API allows access to EAL shared memory configuration through an API.
+ */
+
 #include <rte_fbarray.h>
 
 #ifdef __cplusplus
@@ -38,68 +37,6 @@ struct rte_memseg_list {
 	struct rte_fbarray memseg_arr;
 };
 
-/**
- * the structure for the memory configuration for the RTE.
- * Used by the rte_config structure. It is separated out, as for multi-process
- * support, the memory details should be shared across instances
- */
-struct rte_mem_config {
-	volatile uint32_t magic;   /**< Magic number - Sanity check. */
-
-	/* memory topology */
-	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
-	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
-
-	/**
-	 * current lock nest order
-	 *  - qlock->mlock (ring/hash/lpm)
-	 *  - mplock->qlock->mlock (mempool)
-	 * Notice:
-	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
-	 */
-	rte_rwlock_t mlock;   /**< only used by memzone LIB for thread-safe. */
-	rte_rwlock_t qlock;   /**< used for tailq operation for thread safe. */
-	rte_rwlock_t mplock;  /**< only used by mempool LIB for thread-safe. */
-
-	rte_rwlock_t memory_hotplug_lock;
-	/**< indicates whether memory hotplug request is in progress. */
-
-	/* memory segments and zones */
-	struct rte_fbarray memzones; /**< Memzone descriptors. */
-
-	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
-	/**< list of dynamic arrays holding memsegs */
-
-	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ]; /**< Tailqs for objects */
-
-	/* Heaps of Malloc */
-	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
-
-	/* next socket ID for external malloc heap */
-	int next_socket_id;
-
-	/* address of mem_config in primary process. used to map shared config into
-	 * exact same address the primary process maps it.
-	 */
-	uint64_t mem_cfg_addr;
-
-	/* legacy mem and single file segments options are shared */
-	uint32_t legacy_mem;
-	uint32_t single_file_segments;
-
-	/* keeps the more restricted dma mask */
-	uint8_t dma_maskbits;
-} __attribute__((__packed__));
-
-
-inline static void
-rte_eal_mcfg_wait_complete(struct rte_mem_config* mcfg)
-{
-	/* wait until shared mem_config finish initialising */
-	while(mcfg->magic != RTE_MAGIC)
-		rte_pause();
-}
-
 /**
  * Lock the internal EAL shared memory configuration for shared access.
  */
diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index 0298ec1ca..bd84fcf70 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -20,11 +20,13 @@
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
 #include <rte_memcpy.h>
+#include <rte_memzone.h>
 #include <rte_atomic.h>
 #include <rte_fbarray.h>
 
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "malloc_elem.h"
 #include "malloc_heap.h"
 #include "malloc_mp.h"
diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c
index b470565e0..17b803d59 100644
--- a/lib/librte_eal/common/malloc_mp.c
+++ b/lib/librte_eal/common/malloc_mp.c
@@ -10,6 +10,7 @@
 #include <rte_string_fns.h>
 
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 
 #include "malloc_elem.h"
 #include "malloc_mp.h"
diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index 4d83bf518..0dc900403 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -25,6 +25,7 @@
 #include "malloc_elem.h"
 #include "malloc_heap.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 
 
 /* Free the memory space back to heap */
diff --git a/lib/librte_eal/freebsd/eal/eal_memory.c b/lib/librte_eal/freebsd/eal/eal_memory.c
index 4b092e1f2..9b9a0577a 100644
--- a/lib/librte_eal/freebsd/eal/eal_memory.c
+++ b/lib/librte_eal/freebsd/eal/eal_memory.c
@@ -18,6 +18,7 @@
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
+#include "eal_memcfg.h"
 
 #define EAL_PAGE_SIZE (sysconf(_SC_PAGESIZE))
 
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 161399619..ac2db049b 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -57,6 +57,7 @@
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
+#include "eal_memcfg.h"
 #include "eal_options.h"
 #include "eal_vfio.h"
 
diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c
index 1e9ebb86d..b178ed3ea 100644
--- a/lib/librte_eal/linux/eal/eal_memalloc.c
+++ b/lib/librte_eal/linux/eal/eal_memalloc.c
@@ -45,6 +45,7 @@
 #include "eal_filesystem.h"
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_private.h"
 
 const int anonymous_hugepages_supported =
diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c
index 416dad898..da355f5ea 100644
--- a/lib/librte_eal/linux/eal/eal_memory.c
+++ b/lib/librte_eal/linux/eal/eal_memory.c
@@ -47,6 +47,7 @@
 
 #include "eal_private.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index 36f0d1ca7..cdad4535e 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -15,6 +15,7 @@
 #include <rte_vfio.h>
 
 #include "eal_filesystem.h"
+#include "eal_memcfg.h"
 #include "eal_vfio.h"
 #include "eal_private.h"
 
diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index 71f067df6..ac58ae8ef 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -20,6 +20,7 @@
 #include <rte_ring.h>
 #include <rte_jhash.h>
 #include <rte_hash_crc.h>
+#include <rte_tailq.h>
 
 #include "rte_efd.h"
 #if defined(RTE_ARCH_X86)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index ffe649411..fe44b77f6 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -27,6 +27,7 @@
 #include <rte_ring.h>
 #include <rte_compat.h>
 #include <rte_vect.h>
+#include <rte_tailq.h>
 
 #include "rte_hash.h"
 #include "rte_cuckoo_hash.h"
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index 54a8596ab..f4f4f5e22 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -20,6 +20,7 @@
 #include <rte_cpuflags.h>
 #include <rte_log.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_fbk_hash.h"
 
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index bb1c5b197..94327450d 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -21,6 +21,7 @@
 #include <rte_errno.h>
 #include <rte_rwlock.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_lpm.h"
 
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index 5fabfa3d4..7bb154f9c 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -24,6 +24,7 @@
 #include <rte_hash.h>
 #include <assert.h>
 #include <rte_jhash.h>
+#include <rte_tailq.h>
 
 #include "rte_lpm6.h"
 
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index 70322d86a..997f08d80 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -10,6 +10,7 @@
 #include <rte_memory.h>
 #include <rte_malloc.h>
 #include <rte_errno.h>
+#include <rte_tailq.h>
 
 #include "rte_member.h"
 #include "rte_member_ht.h"
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index c98233828..18269a6d0 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -30,6 +30,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_mempool.h"
 
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index c505a4810..8848bd544 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -11,6 +11,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
 #include <rte_malloc.h>
+#include <rte_tailq.h>
 
 #include "rte_reorder.h"
 
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index 8d0744153..d23e66fa2 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -30,6 +30,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_ring.h"
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 25/25] eal: hide shared memory config
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 25/25] eal: hide " Anatoly Burakov
@ 2019-05-29 16:40   ` Stephen Hemminger
  2019-05-30  8:02     ` Burakov, Anatoly
  2019-05-29 20:14   ` David Marchand
  1 sibling, 1 reply; 117+ messages in thread
From: Stephen Hemminger @ 2019-05-29 16:40 UTC (permalink / raw)
  To: Anatoly Burakov
  Cc: dev, Konstantin Ananyev, David Hunt, Bruce Richardson,
	Byron Marohn, Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Reshma Pattan, thomas, david.marchand

On Wed, 29 May 2019 17:31:11 +0100
Anatoly Burakov <anatoly.burakov@intel.com> wrote:

> +static inline void
> +rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
> +{
> +	/* wait until shared mem_config finish initialising */
> +	while (mcfg->magic != RTE_MAGIC)
> +		rte_pause();
> +}
>

Not fast path, why is this inline?

> +#endif // EAL_MEMCFG_H

Avoid C++ style comments.

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 01/25] eal: add API to lock/unlock memory hotplug
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 01/25] eal: add API to lock/unlock memory hotplug Anatoly Burakov
@ 2019-05-29 16:41   ` Stephen Hemminger
  0 siblings, 0 replies; 117+ messages in thread
From: Stephen Hemminger @ 2019-05-29 16:41 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, thomas, david.marchand

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.

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 17/25] mempool: use new tailq locking API
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 17/25] mempool: " Anatoly Burakov
@ 2019-05-29 16:47   ` Andrew Rybchenko
  0 siblings, 0 replies; 117+ messages in thread
From: Andrew Rybchenko @ 2019-05-29 16:47 UTC (permalink / raw)
  To: Anatoly Burakov, dev; +Cc: Olivier Matz, stephen, thomas, david.marchand

On 5/29/19 7:31 PM, Anatoly Burakov wrote:
> Replace usages of direct access to shared memory config with
> calls to the new API.
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>


^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 22/25] mempool: use new mempool list locking API
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 22/25] mempool: use new mempool list locking API Anatoly Burakov
@ 2019-05-29 16:50   ` Andrew Rybchenko
  0 siblings, 0 replies; 117+ messages in thread
From: Andrew Rybchenko @ 2019-05-29 16:50 UTC (permalink / raw)
  To: Anatoly Burakov, dev; +Cc: Olivier Matz, stephen, thomas, david.marchand

On 5/29/19 7:31 PM, Anatoly Burakov wrote:
> Replace usages of direct access to shared memory config with
> calls to the new API.
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>


^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 20/25] stack: use new tailq locking API
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 20/25] stack: " Anatoly Burakov
@ 2019-05-29 18:20   ` Eads, Gage
  0 siblings, 0 replies; 117+ messages in thread
From: Eads, Gage @ 2019-05-29 18:20 UTC (permalink / raw)
  To: Burakov, Anatoly, dev; +Cc: Olivier Matz, stephen, thomas, david.marchand

> Replace usages of direct access to shared memory config with calls to the
> new API.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Acked-by: Gage Eads <gage.eads@intel.com>

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 00/25] Make shared memory config non-public
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (24 preceding siblings ...)
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 25/25] eal: hide " Anatoly Burakov
@ 2019-05-29 20:11 ` David Marchand
  2019-05-30  8:07   ` Burakov, Anatoly
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                   ` (14 subsequent siblings)
  40 siblings, 1 reply; 117+ messages in thread
From: David Marchand @ 2019-05-29 20:11 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Stephen Hemminger, Thomas Monjalon

On Wed, May 29, 2019 at 6:31 PM Anatoly Burakov <anatoly.burakov@intel.com>
wrote:

> This patchset removes the shared memory config from public
> API, and replaces all usages of said config with new API
> calls.
>
> The patchset is mostly a search-and-replace job and should
> be pretty easy to review. However, the changes to ENA
>

I went and did the same job with some scripts.

Not sure you really need to split in all those patches.
We are not going to backport this.
Some changes are mixed, the kni changes are in the hash: patch.


I spotted a missed qlock in :
lib/librte_eal/common/eal_common_tailqs.c:
 rte_rwlock_read_lock(&mcfg->qlock);
lib/librte_eal/common/eal_common_tailqs.c:
 rte_rwlock_read_unlock(&mcfg->qlock);


On the names of the functions, could we have something shorter ?
The prefix rte_eal_mcfg_ is not necessary from my pov.


driver are of particular interest, because they're using
> the shared memory config in a way that i find confusing.
>

I thought the same when I looked at it before.
Hopefully the ena maintainers will enlight us :-).


I tried to implement the equivalent changes as well as
> i could, but since the code doesn't make any sense to me,
> i would really like to request help from ENA maintainers.
>
> Everything else should be pretty straightforward.
>

We are missing the deprecation notice removal at the end of the series and
a note in the release notes.

Thanks Anatoly!


-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 25/25] eal: hide shared memory config
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 25/25] eal: hide " Anatoly Burakov
  2019-05-29 16:40   ` Stephen Hemminger
@ 2019-05-29 20:14   ` David Marchand
  1 sibling, 0 replies; 117+ messages in thread
From: David Marchand @ 2019-05-29 20:14 UTC (permalink / raw)
  To: Anatoly Burakov
  Cc: dev, Konstantin Ananyev, David Hunt, Bruce Richardson,
	Byron Marohn, Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Reshma Pattan, Stephen Hemminger, Thomas Monjalon

On Wed, May 29, 2019 at 6:32 PM Anatoly Burakov <anatoly.burakov@intel.com>
wrote:

> diff --git a/lib/librte_eal/common/eal_memcfg.h
> b/lib/librte_eal/common/eal_memcfg.h
> new file mode 100644
> index 000000000..75891e6cb
> --- /dev/null
> +++ b/lib/librte_eal/common/eal_memcfg.h
> @@ -0,0 +1,75 @@
>

Missing a license banner here ?


+#ifndef EAL_MEMCFG_H
> +#define EAL_MEMCFG_H
> +
> +#include <rte_config.h>
> +#include <rte_eal_memconfig.h>
> +#include <rte_malloc_heap.h>
> +#include <rte_memory.h>
> +#include <rte_memzone.h>
> +#include <rte_pause.h>
> +#include <rte_rwlock.h>
> +#include <rte_tailq.h>
> +
> +/**
> + * the structure for the memory configuration for the RTE.
> + * Used by the rte_config structure. It is separated out, as for
> multi-process
> + * support, the memory details should be shared across instances
> + */
> +struct rte_mem_config {
> +       volatile uint32_t magic;   /**< Magic number - Sanity check. */
> +
> +       /* memory topology */
> +       uint32_t nchannel;    /**< Number of channels (0 if unknown). */
> +       uint32_t nrank;       /**< Number of ranks (0 if unknown). */
> +
> +       /**
> +        * current lock nest order
> +        *  - qlock->mlock (ring/hash/lpm)
> +        *  - mplock->qlock->mlock (mempool)
> +        * Notice:
> +        *  *ALWAYS* obtain qlock first if having to obtain both qlock and
> mlock
> +        */
> +       rte_rwlock_t mlock;   /**< only used by memzone LIB for
> thread-safe. */
> +       rte_rwlock_t qlock;   /**< used for tailq operation for thread
> safe. */
> +       rte_rwlock_t mplock;  /**< only used by mempool LIB for
> thread-safe. */
> +
> +       rte_rwlock_t memory_hotplug_lock;
> +       /**< indicates whether memory hotplug request is in progress. */
> +
> +       /* memory segments and zones */
> +       struct rte_fbarray memzones; /**< Memzone descriptors. */
> +
> +       struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
> +       /**< list of dynamic arrays holding memsegs */
> +
> +       struct rte_tailq_head tailq_head[RTE_MAX_TAILQ];
> +       /**< Tailqs for objects */
> +
> +       /* Heaps of Malloc */
> +       struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
> +
> +       /* next socket ID for external malloc heap */
> +       int next_socket_id;
> +
> +       /* address of mem_config in primary process. used to map shared
> config
> +        * into exact same address the primary process maps it.
> +        */
> +       uint64_t mem_cfg_addr;
> +
> +       /* legacy mem and single file segments options are shared */
> +       uint32_t legacy_mem;
> +       uint32_t single_file_segments;
> +
> +       /* keeps the more restricted dma mask */
> +       uint8_t dma_maskbits;
> +} __attribute__((packed));
> +
> +static inline void
> +rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
> +{
> +       /* wait until shared mem_config finish initialising */
> +       while (mcfg->magic != RTE_MAGIC)
> +               rte_pause();
> +}
>

A bit similar to what Stephen said, this could be in a .c.


-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 05/25] net/virtio: use new memory locking API
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 05/25] net/virtio: " Anatoly Burakov
@ 2019-05-30  6:39   ` Tiwei Bie
  0 siblings, 0 replies; 117+ messages in thread
From: Tiwei Bie @ 2019-05-30  6:39 UTC (permalink / raw)
  To: Anatoly Burakov
  Cc: dev, Maxime Coquelin, Zhihong Wang, stephen, thomas, david.marchand


[PATCH 05/25] net/virtio: use new memory locking API

A minor nit: net/virtio -> net/virtio-user

For the rest,
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>

On Wed, May 29, 2019 at 05:30:51PM +0100, Anatoly Burakov wrote:
> Replace usages of direct access to shared memory config with
> calls to the new API.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
[...]

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 25/25] eal: hide shared memory config
  2019-05-29 16:40   ` Stephen Hemminger
@ 2019-05-30  8:02     ` Burakov, Anatoly
  0 siblings, 0 replies; 117+ messages in thread
From: Burakov, Anatoly @ 2019-05-30  8:02 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: dev, Konstantin Ananyev, David Hunt, Bruce Richardson,
	Byron Marohn, Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Reshma Pattan, thomas, david.marchand

On 29-May-19 5:40 PM, Stephen Hemminger wrote:
> On Wed, 29 May 2019 17:31:11 +0100
> Anatoly Burakov <anatoly.burakov@intel.com> wrote:
> 
>> +static inline void
>> +rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
>> +{
>> +	/* wait until shared mem_config finish initialising */
>> +	while (mcfg->magic != RTE_MAGIC)
>> +		rte_pause();
>> +}
>>
> 
> Not fast path, why is this inline?

I kept existing function. Have no preference one way or the other, can 
change in V2.

> 
>> +#endif // EAL_MEMCFG_H
> 
> Avoid C++ style comments.
> 

Will fix.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 00/25] Make shared memory config non-public
  2019-05-29 20:11 ` [dpdk-dev] [PATCH 00/25] Make shared memory config non-public David Marchand
@ 2019-05-30  8:07   ` Burakov, Anatoly
  2019-05-30 10:15     ` Bruce Richardson
  0 siblings, 1 reply; 117+ messages in thread
From: Burakov, Anatoly @ 2019-05-30  8:07 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Stephen Hemminger, Thomas Monjalon

On 29-May-19 9:11 PM, David Marchand wrote:
> On Wed, May 29, 2019 at 6:31 PM Anatoly Burakov <anatoly.burakov@intel.com>
> wrote:
> 
>> This patchset removes the shared memory config from public
>> API, and replaces all usages of said config with new API
>> calls.
>>
>> The patchset is mostly a search-and-replace job and should
>> be pretty easy to review. However, the changes to ENA
>>
> 
> I went and did the same job with some scripts.
> 
> Not sure you really need to split in all those patches.
> We are not going to backport this.

The "separate commits" thing is made for the benefit of reviewers, not 
backporters. In my experience it's much easier to get a maintainer to 
review a smaller patch than it is to look through a wall of irrelevant 
changes.

That said, for trivial changes such as these, maybe this is indeed 
unnecessary.

> Some changes are mixed, the kni changes are in the hash: patch.

Oops, will fix, thanks for pointing it out!

> 
> 
> I spotted a missed qlock in :
> lib/librte_eal/common/eal_common_tailqs.c:
>   rte_rwlock_read_lock(&mcfg->qlock);
> lib/librte_eal/common/eal_common_tailqs.c:
>   rte_rwlock_read_unlock(&mcfg->qlock);
> 
> 
> On the names of the functions, could we have something shorter ?
> The prefix rte_eal_mcfg_ is not necessary from my pov.

I can drop the mcfg, but IMO all of these locking functions should be 
kept under one namespace, and rte_eal_ is too broad.

> 
> 
> driver are of particular interest, because they're using
>> the shared memory config in a way that i find confusing.
>>
> 
> I thought the same when I looked at it before.
> Hopefully the ena maintainers will enlight us :-).
> 
> 
> I tried to implement the equivalent changes as well as
>> i could, but since the code doesn't make any sense to me,
>> i would really like to request help from ENA maintainers.
>>
>> Everything else should be pretty straightforward.
>>
> 
> We are missing the deprecation notice removal at the end of the series and
> a note in the release notes.

Will add. Making into V1 deadline was higher priority :D

> 
> Thanks Anatoly!
> 
> 


-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 00/25] Make shared memory config non-public
  2019-05-30  8:07   ` Burakov, Anatoly
@ 2019-05-30 10:15     ` Bruce Richardson
  2019-06-03  9:42       ` Thomas Monjalon
  0 siblings, 1 reply; 117+ messages in thread
From: Bruce Richardson @ 2019-05-30 10:15 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: David Marchand, dev, Stephen Hemminger, Thomas Monjalon

On Thu, May 30, 2019 at 09:07:44AM +0100, Burakov, Anatoly wrote:
> On 29-May-19 9:11 PM, David Marchand wrote:
> > On Wed, May 29, 2019 at 6:31 PM Anatoly Burakov <anatoly.burakov@intel.com>
> > wrote:
> > 
> > > This patchset removes the shared memory config from public
> > > API, and replaces all usages of said config with new API
> > > calls.
> > > 
> > > The patchset is mostly a search-and-replace job and should
> > > be pretty easy to review. However, the changes to ENA
> > > 
> > 
> > I went and did the same job with some scripts.
> > 
> > Not sure you really need to split in all those patches.
> > We are not going to backport this.
> 
> The "separate commits" thing is made for the benefit of reviewers, not
> backporters. In my experience it's much easier to get a maintainer to review
> a smaller patch than it is to look through a wall of irrelevant changes.
> 
> That said, for trivial changes such as these, maybe this is indeed
> unnecessary.
> 
> > Some changes are mixed, the kni changes are in the hash: patch.
> 
> Oops, will fix, thanks for pointing it out!
> 
> > 
> > 
> > I spotted a missed qlock in :
> > lib/librte_eal/common/eal_common_tailqs.c:
> >   rte_rwlock_read_lock(&mcfg->qlock);
> > lib/librte_eal/common/eal_common_tailqs.c:
> >   rte_rwlock_read_unlock(&mcfg->qlock);
> > 
> > 
> > On the names of the functions, could we have something shorter ?
> > The prefix rte_eal_mcfg_ is not necessary from my pov.
> 
> I can drop the mcfg, but IMO all of these locking functions should be kept
> under one namespace, and rte_eal_ is too broad.
> 

I think most/all developers are aware that memory is part of eal, so
rte_mcfg_ prefix (or rte_memcfg) might work.

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 02/25] bus/fslmc: use new memory locking API
  2019-05-29 16:30 ` [dpdk-dev] [PATCH 02/25] bus/fslmc: use new memory locking API Anatoly Burakov
@ 2019-06-03  6:41   ` Shreyansh Jain
  0 siblings, 0 replies; 117+ messages in thread
From: Shreyansh Jain @ 2019-06-03  6:41 UTC (permalink / raw)
  To: Anatoly Burakov, dev; +Cc: Hemant Agrawal, stephen, thomas, david.marchand

> -----Original Message-----
> From: Anatoly Burakov <anatoly.burakov@intel.com>
> Sent: Wednesday, May 29, 2019 10:01 PM
> To: dev@dpdk.org
> Cc: Hemant Agrawal <hemant.agrawal@nxp.com>; Shreyansh Jain
> <shreyansh.jain@nxp.com>; stephen@networkplumber.org;
> thomas@monjalon.net; david.marchand@redhat.com
> Subject: [PATCH 02/25] bus/fslmc: use new memory locking API
> 
> Replace usages of direct access to shared memory config with
> calls to the new API.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---

From fslmc perspective, looks fine to me.

Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 24/25] net/ena: fix direct access to shared memory config
  2019-05-29 16:31 ` [dpdk-dev] [PATCH 24/25] net/ena: fix direct access to shared memory config Anatoly Burakov
@ 2019-06-03  7:33   ` Michał Krawczyk
  2019-06-03 13:36     ` Michał Krawczyk
  0 siblings, 1 reply; 117+ messages in thread
From: Michał Krawczyk @ 2019-06-03  7:33 UTC (permalink / raw)
  To: Anatoly Burakov, dev
  Cc: Marcin Wojtas, Guy Tzalik, Evgeny Schemeilin, stephen, thomas,
	david.marchand

On 29.05.2019 18:31, Anatoly Burakov wrote:
> The ENA driver calculates a ring's NUMA node affinity by directly
> accessing the memzone list. Fix it to do it through the public
> API's instead.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>   drivers/net/ena/ena_ethdev.c | 18 +++---------------
>   1 file changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
> index b6651fc0f..e745e9e92 100644
> --- a/drivers/net/ena/ena_ethdev.c
> +++ b/drivers/net/ena/ena_ethdev.c
> @@ -274,20 +274,6 @@ static const struct eth_dev_ops ena_dev_ops = {
>   
>   #define NUMA_NO_NODE	SOCKET_ID_ANY
>   
> -static inline int ena_cpu_to_node(int cpu)
> -{
> -	struct rte_config *config = rte_eal_get_configuration();
> -	struct rte_fbarray *arr = &config->mem_config->memzones;
> -	const struct rte_memzone *mz;
> -
> -	if (unlikely(cpu >= RTE_MAX_MEMZONE))
> -		return NUMA_NO_NODE;
> -
> -	mz = rte_fbarray_get(arr, cpu);
> -
> -	return mz->socket_id;
> -}
> -
>   static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
>   				       struct ena_com_rx_ctx *ena_rx_ctx)
>   {
> @@ -1099,6 +1085,7 @@ static int ena_create_io_queue(struct ena_ring *ring)
>   {
>   	struct ena_adapter *adapter;
>   	struct ena_com_dev *ena_dev;
> +	struct rte_memseg_list *msl;
>   	struct ena_com_create_io_ctx ctx =
>   		/* policy set to _HOST just to satisfy icc compiler */
>   		{ ENA_ADMIN_PLACEMENT_POLICY_HOST,
> @@ -1126,7 +1113,8 @@ static int ena_create_io_queue(struct ena_ring *ring)
>   	}
>   	ctx.qid = ena_qid;
>   	ctx.msix_vector = -1; /* interrupts not used */
> -	ctx.numa_node = ena_cpu_to_node(ring->id);
> +	msl = rte_mem_virt2memseg_list(ring);
> +	ctx.numa_node = msl->socket_id;
>   
>   	rc = ena_com_create_io_queue(ena_dev, &ctx);
>   	if (rc) {
> 

Hi Anatoly,

I'm not sure why the previous maintainers implemented this that way, I 
can only guess. I think that they were assuming, that each queue will be 
assigned to the lcore which is equal to ring id. They probably also 
misunderstood how the memzones are working and they thought that each 
lcore is having assigned only one memzone which is being mapped 1 to 1.

They wanted to prevent cross NUMA data acces, when the CPU is operating 
in the different NUMA zone and the IO queues memory resides in the 
other. I think that above solution won't prevent that neither, as you 
are using ring address, which is being allocated together with
struct ena_adapter (it is just an array), so it will probably reside in 
the single numa zone.

I'm currently thinking on solution that could help us to determine on 
which numa zone the queue descriptors will be allocated and on which the 
lcore assigned to the queue will be working, but have no any ideas for 
now :)

Anyway, your fix won't break anything, as the previous solution wasn't 
working as it was supposed to work, so before I will fix that, we can 
keep that patch to prevent direct usage of the memzone.

Thanks,
Michal

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 00/25] Make shared memory config non-public
  2019-05-30 10:15     ` Bruce Richardson
@ 2019-06-03  9:42       ` Thomas Monjalon
  0 siblings, 0 replies; 117+ messages in thread
From: Thomas Monjalon @ 2019-06-03  9:42 UTC (permalink / raw)
  To: Bruce Richardson, Burakov, Anatoly, David Marchand; +Cc: dev, Stephen Hemminger

30/05/2019 12:15, Bruce Richardson:
> On Thu, May 30, 2019 at 09:07:44AM +0100, Burakov, Anatoly wrote:
> > On 29-May-19 9:11 PM, David Marchand wrote:
> > > On the names of the functions, could we have something shorter ?
> > > The prefix rte_eal_mcfg_ is not necessary from my pov.
> > 
> > I can drop the mcfg, but IMO all of these locking functions should be kept
> > under one namespace, and rte_eal_ is too broad.
> 
> I think most/all developers are aware that memory is part of eal, so
> rte_mcfg_ prefix (or rte_memcfg) might work.

Why not being explicit with "rte_mem_config_",
same as the structure?




^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 24/25] net/ena: fix direct access to shared memory config
  2019-06-03  7:33   ` Michał Krawczyk
@ 2019-06-03 13:36     ` Michał Krawczyk
  2019-06-04 10:28       ` Burakov, Anatoly
  0 siblings, 1 reply; 117+ messages in thread
From: Michał Krawczyk @ 2019-06-03 13:36 UTC (permalink / raw)
  To: Anatoly Burakov, dev
  Cc: Marcin Wojtas, Guy Tzalik, Evgeny Schemeilin, stephen, thomas,
	david.marchand

On 03.06.2019 09:33, Michał Krawczyk wrote:
> On 29.05.2019 18:31, Anatoly Burakov wrote:
>> The ENA driver calculates a ring's NUMA node affinity by directly
>> accessing the memzone list. Fix it to do it through the public
>> API's instead.
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>> ---
>>   drivers/net/ena/ena_ethdev.c | 18 +++---------------
>>   1 file changed, 3 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
>> index b6651fc0f..e745e9e92 100644
>> --- a/drivers/net/ena/ena_ethdev.c
>> +++ b/drivers/net/ena/ena_ethdev.c
>> @@ -274,20 +274,6 @@ static const struct eth_dev_ops ena_dev_ops = {
>>   #define NUMA_NO_NODE    SOCKET_ID_ANY
>> -static inline int ena_cpu_to_node(int cpu)
>> -{
>> -    struct rte_config *config = rte_eal_get_configuration();
>> -    struct rte_fbarray *arr = &config->mem_config->memzones;
>> -    const struct rte_memzone *mz;
>> -
>> -    if (unlikely(cpu >= RTE_MAX_MEMZONE))
>> -        return NUMA_NO_NODE;
>> -
>> -    mz = rte_fbarray_get(arr, cpu);
>> -
>> -    return mz->socket_id;
>> -}
>> -
>>   static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
>>                          struct ena_com_rx_ctx *ena_rx_ctx)
>>   {
>> @@ -1099,6 +1085,7 @@ static int ena_create_io_queue(struct ena_ring 
>> *ring)
>>   {
>>       struct ena_adapter *adapter;
>>       struct ena_com_dev *ena_dev;
>> +    struct rte_memseg_list *msl;
>>       struct ena_com_create_io_ctx ctx =
>>           /* policy set to _HOST just to satisfy icc compiler */
>>           { ENA_ADMIN_PLACEMENT_POLICY_HOST,
>> @@ -1126,7 +1113,8 @@ static int ena_create_io_queue(struct ena_ring 
>> *ring)
>>       }
>>       ctx.qid = ena_qid;
>>       ctx.msix_vector = -1; /* interrupts not used */
>> -    ctx.numa_node = ena_cpu_to_node(ring->id);
>> +    msl = rte_mem_virt2memseg_list(ring);
>> +    ctx.numa_node = msl->socket_id;
>>       rc = ena_com_create_io_queue(ena_dev, &ctx);
>>       if (rc) {
>>
> 
> Hi Anatoly,
> 
> I'm not sure why the previous maintainers implemented this that way, I 
> can only guess. I think that they were assuming, that each queue will be 
> assigned to the lcore which is equal to ring id. They probably also 
> misunderstood how the memzones are working and they thought that each 
> lcore is having assigned only one memzone which is being mapped 1 to 1.
> 
> They wanted to prevent cross NUMA data acces, when the CPU is operating 
> in the different NUMA zone and the IO queues memory resides in the 
> other. I think that above solution won't prevent that neither, as you 
> are using ring address, which is being allocated together with
> struct ena_adapter (it is just an array), so it will probably reside in 
> the single numa zone.
> 
> I'm currently thinking on solution that could help us to determine on 
> which numa zone the queue descriptors will be allocated and on which the 
> lcore assigned to the queue will be working, but have no any ideas for 
> now :)
> 
> Anyway, your fix won't break anything, as the previous solution wasn't 
> working as it was supposed to work, so before I will fix that, we can 
> keep that patch to prevent direct usage of the memzone.
> 
> Thanks,
> Michal

After investigation I think that we should use socket_id provided by the 
tx/rx queue setup functions.
Could you, please, abandon this patch? I will send the proper fix soon.

Thanks,
Michal

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 24/25] net/ena: fix direct access to shared memory config
  2019-06-03 13:36     ` Michał Krawczyk
@ 2019-06-04 10:28       ` Burakov, Anatoly
  2019-06-04 10:45         ` Michał Krawczyk
  0 siblings, 1 reply; 117+ messages in thread
From: Burakov, Anatoly @ 2019-06-04 10:28 UTC (permalink / raw)
  To: Michał Krawczyk, dev
  Cc: Marcin Wojtas, Guy Tzalik, Evgeny Schemeilin, stephen, thomas,
	david.marchand

On 03-Jun-19 2:36 PM, Michał Krawczyk wrote:
> On 03.06.2019 09:33, Michał Krawczyk wrote:
>> On 29.05.2019 18:31, Anatoly Burakov wrote:
>>> The ENA driver calculates a ring's NUMA node affinity by directly
>>> accessing the memzone list. Fix it to do it through the public
>>> API's instead.
>>>
>>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>>> ---
>>>   drivers/net/ena/ena_ethdev.c | 18 +++---------------
>>>   1 file changed, 3 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
>>> index b6651fc0f..e745e9e92 100644
>>> --- a/drivers/net/ena/ena_ethdev.c
>>> +++ b/drivers/net/ena/ena_ethdev.c
>>> @@ -274,20 +274,6 @@ static const struct eth_dev_ops ena_dev_ops = {
>>>   #define NUMA_NO_NODE    SOCKET_ID_ANY
>>> -static inline int ena_cpu_to_node(int cpu)
>>> -{
>>> -    struct rte_config *config = rte_eal_get_configuration();
>>> -    struct rte_fbarray *arr = &config->mem_config->memzones;
>>> -    const struct rte_memzone *mz;
>>> -
>>> -    if (unlikely(cpu >= RTE_MAX_MEMZONE))
>>> -        return NUMA_NO_NODE;
>>> -
>>> -    mz = rte_fbarray_get(arr, cpu);
>>> -
>>> -    return mz->socket_id;
>>> -}
>>> -
>>>   static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
>>>                          struct ena_com_rx_ctx *ena_rx_ctx)
>>>   {
>>> @@ -1099,6 +1085,7 @@ static int ena_create_io_queue(struct ena_ring 
>>> *ring)
>>>   {
>>>       struct ena_adapter *adapter;
>>>       struct ena_com_dev *ena_dev;
>>> +    struct rte_memseg_list *msl;
>>>       struct ena_com_create_io_ctx ctx =
>>>           /* policy set to _HOST just to satisfy icc compiler */
>>>           { ENA_ADMIN_PLACEMENT_POLICY_HOST,
>>> @@ -1126,7 +1113,8 @@ static int ena_create_io_queue(struct ena_ring 
>>> *ring)
>>>       }
>>>       ctx.qid = ena_qid;
>>>       ctx.msix_vector = -1; /* interrupts not used */
>>> -    ctx.numa_node = ena_cpu_to_node(ring->id);
>>> +    msl = rte_mem_virt2memseg_list(ring);
>>> +    ctx.numa_node = msl->socket_id;
>>>       rc = ena_com_create_io_queue(ena_dev, &ctx);
>>>       if (rc) {
>>>
>>
>> Hi Anatoly,
>>
>> I'm not sure why the previous maintainers implemented this that way, I 
>> can only guess. I think that they were assuming, that each queue will 
>> be assigned to the lcore which is equal to ring id. They probably also 
>> misunderstood how the memzones are working and they thought that each 
>> lcore is having assigned only one memzone which is being mapped 1 to 1.
>>
>> They wanted to prevent cross NUMA data acces, when the CPU is 
>> operating in the different NUMA zone and the IO queues memory resides 
>> in the other. I think that above solution won't prevent that neither, 
>> as you are using ring address, which is being allocated together with
>> struct ena_adapter (it is just an array), so it will probably reside 
>> in the single numa zone.
>>
>> I'm currently thinking on solution that could help us to determine on 
>> which numa zone the queue descriptors will be allocated and on which 
>> the lcore assigned to the queue will be working, but have no any ideas 
>> for now :)
>>
>> Anyway, your fix won't break anything, as the previous solution wasn't 
>> working as it was supposed to work, so before I will fix that, we can 
>> keep that patch to prevent direct usage of the memzone.
>>
>> Thanks,
>> Michal
> 
> After investigation I think that we should use socket_id provided by the 
> tx/rx queue setup functions.
> Could you, please, abandon this patch? I will send the proper fix soon.
> 

I can't really "abandon" it as it will break ENA compilation once the 
structure is hidden in the last patch. What i can do is wait for you to 
submit your patch, and either rebase my patchset on top of it, or 
(better) include it in the patchset itself.

> Thanks,
> Michal
> 


-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 24/25] net/ena: fix direct access to shared memory config
  2019-06-04 10:28       ` Burakov, Anatoly
@ 2019-06-04 10:45         ` Michał Krawczyk
  2019-06-04 12:38           ` Burakov, Anatoly
  0 siblings, 1 reply; 117+ messages in thread
From: Michał Krawczyk @ 2019-06-04 10:45 UTC (permalink / raw)
  To: Burakov, Anatoly
  Cc: dev, Marcin Wojtas, Guy Tzalik, Evgeny Schemeilin, stephen,
	Thomas Monjalon, david.marchand

wt., 4 cze 2019 o 12:28 Burakov, Anatoly <anatoly.burakov@intel.com> napisał(a):
>
> On 03-Jun-19 2:36 PM, Michał Krawczyk wrote:
> > On 03.06.2019 09:33, Michał Krawczyk wrote:
> >> On 29.05.2019 18:31, Anatoly Burakov wrote:
> >>> The ENA driver calculates a ring's NUMA node affinity by directly
> >>> accessing the memzone list. Fix it to do it through the public
> >>> API's instead.
> >>>
> >>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> >>> ---
> >>>   drivers/net/ena/ena_ethdev.c | 18 +++---------------
> >>>   1 file changed, 3 insertions(+), 15 deletions(-)
> >>>
> >>> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
> >>> index b6651fc0f..e745e9e92 100644
> >>> --- a/drivers/net/ena/ena_ethdev.c
> >>> +++ b/drivers/net/ena/ena_ethdev.c
> >>> @@ -274,20 +274,6 @@ static const struct eth_dev_ops ena_dev_ops = {
> >>>   #define NUMA_NO_NODE    SOCKET_ID_ANY
> >>> -static inline int ena_cpu_to_node(int cpu)
> >>> -{
> >>> -    struct rte_config *config = rte_eal_get_configuration();
> >>> -    struct rte_fbarray *arr = &config->mem_config->memzones;
> >>> -    const struct rte_memzone *mz;
> >>> -
> >>> -    if (unlikely(cpu >= RTE_MAX_MEMZONE))
> >>> -        return NUMA_NO_NODE;
> >>> -
> >>> -    mz = rte_fbarray_get(arr, cpu);
> >>> -
> >>> -    return mz->socket_id;
> >>> -}
> >>> -
> >>>   static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
> >>>                          struct ena_com_rx_ctx *ena_rx_ctx)
> >>>   {
> >>> @@ -1099,6 +1085,7 @@ static int ena_create_io_queue(struct ena_ring
> >>> *ring)
> >>>   {
> >>>       struct ena_adapter *adapter;
> >>>       struct ena_com_dev *ena_dev;
> >>> +    struct rte_memseg_list *msl;
> >>>       struct ena_com_create_io_ctx ctx =
> >>>           /* policy set to _HOST just to satisfy icc compiler */
> >>>           { ENA_ADMIN_PLACEMENT_POLICY_HOST,
> >>> @@ -1126,7 +1113,8 @@ static int ena_create_io_queue(struct ena_ring
> >>> *ring)
> >>>       }
> >>>       ctx.qid = ena_qid;
> >>>       ctx.msix_vector = -1; /* interrupts not used */
> >>> -    ctx.numa_node = ena_cpu_to_node(ring->id);
> >>> +    msl = rte_mem_virt2memseg_list(ring);
> >>> +    ctx.numa_node = msl->socket_id;
> >>>       rc = ena_com_create_io_queue(ena_dev, &ctx);
> >>>       if (rc) {
> >>>
> >>
> >> Hi Anatoly,
> >>
> >> I'm not sure why the previous maintainers implemented this that way, I
> >> can only guess. I think that they were assuming, that each queue will
> >> be assigned to the lcore which is equal to ring id. They probably also
> >> misunderstood how the memzones are working and they thought that each
> >> lcore is having assigned only one memzone which is being mapped 1 to 1.
> >>
> >> They wanted to prevent cross NUMA data acces, when the CPU is
> >> operating in the different NUMA zone and the IO queues memory resides
> >> in the other. I think that above solution won't prevent that neither,
> >> as you are using ring address, which is being allocated together with
> >> struct ena_adapter (it is just an array), so it will probably reside
> >> in the single numa zone.
> >>
> >> I'm currently thinking on solution that could help us to determine on
> >> which numa zone the queue descriptors will be allocated and on which
> >> the lcore assigned to the queue will be working, but have no any ideas
> >> for now :)
> >>
> >> Anyway, your fix won't break anything, as the previous solution wasn't
> >> working as it was supposed to work, so before I will fix that, we can
> >> keep that patch to prevent direct usage of the memzone.
> >>
> >> Thanks,
> >> Michal
> >
> > After investigation I think that we should use socket_id provided by the
> > tx/rx queue setup functions.
> > Could you, please, abandon this patch? I will send the proper fix soon.
> >
>
> I can't really "abandon" it as it will break ENA compilation once the
> structure is hidden in the last patch. What i can do is wait for you to
> submit your patch, and either rebase my patchset on top of it, or
> (better) include it in the patchset itself.

Ok, I've just uploaded the patch (second version has fixed commit
log), you can find it below
https://patches.dpdk.org/patch/54352/

I'm fine with including the patch into this patchset.

>
> > Thanks,
> > Michal
> >
>
>
> --
> Thanks,
> Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH 24/25] net/ena: fix direct access to shared memory config
  2019-06-04 10:45         ` Michał Krawczyk
@ 2019-06-04 12:38           ` Burakov, Anatoly
  0 siblings, 0 replies; 117+ messages in thread
From: Burakov, Anatoly @ 2019-06-04 12:38 UTC (permalink / raw)
  To: Michał Krawczyk
  Cc: dev, Marcin Wojtas, Guy Tzalik, Evgeny Schemeilin, stephen,
	Thomas Monjalon, david.marchand

On 04-Jun-19 11:45 AM, Michał Krawczyk wrote:
> wt., 4 cze 2019 o 12:28 Burakov, Anatoly <anatoly.burakov@intel.com> napisał(a):
>>
>> On 03-Jun-19 2:36 PM, Michał Krawczyk wrote:
>>> On 03.06.2019 09:33, Michał Krawczyk wrote:
>>>> On 29.05.2019 18:31, Anatoly Burakov wrote:
>>>>> The ENA driver calculates a ring's NUMA node affinity by directly
>>>>> accessing the memzone list. Fix it to do it through the public
>>>>> API's instead.
>>>>>
>>>>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>>>>> ---
>>>>>    drivers/net/ena/ena_ethdev.c | 18 +++---------------
>>>>>    1 file changed, 3 insertions(+), 15 deletions(-)
>>>>>
>>>>> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
>>>>> index b6651fc0f..e745e9e92 100644
>>>>> --- a/drivers/net/ena/ena_ethdev.c
>>>>> +++ b/drivers/net/ena/ena_ethdev.c
>>>>> @@ -274,20 +274,6 @@ static const struct eth_dev_ops ena_dev_ops = {
>>>>>    #define NUMA_NO_NODE    SOCKET_ID_ANY
>>>>> -static inline int ena_cpu_to_node(int cpu)
>>>>> -{
>>>>> -    struct rte_config *config = rte_eal_get_configuration();
>>>>> -    struct rte_fbarray *arr = &config->mem_config->memzones;
>>>>> -    const struct rte_memzone *mz;
>>>>> -
>>>>> -    if (unlikely(cpu >= RTE_MAX_MEMZONE))
>>>>> -        return NUMA_NO_NODE;
>>>>> -
>>>>> -    mz = rte_fbarray_get(arr, cpu);
>>>>> -
>>>>> -    return mz->socket_id;
>>>>> -}
>>>>> -
>>>>>    static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
>>>>>                           struct ena_com_rx_ctx *ena_rx_ctx)
>>>>>    {
>>>>> @@ -1099,6 +1085,7 @@ static int ena_create_io_queue(struct ena_ring
>>>>> *ring)
>>>>>    {
>>>>>        struct ena_adapter *adapter;
>>>>>        struct ena_com_dev *ena_dev;
>>>>> +    struct rte_memseg_list *msl;
>>>>>        struct ena_com_create_io_ctx ctx =
>>>>>            /* policy set to _HOST just to satisfy icc compiler */
>>>>>            { ENA_ADMIN_PLACEMENT_POLICY_HOST,
>>>>> @@ -1126,7 +1113,8 @@ static int ena_create_io_queue(struct ena_ring
>>>>> *ring)
>>>>>        }
>>>>>        ctx.qid = ena_qid;
>>>>>        ctx.msix_vector = -1; /* interrupts not used */
>>>>> -    ctx.numa_node = ena_cpu_to_node(ring->id);
>>>>> +    msl = rte_mem_virt2memseg_list(ring);
>>>>> +    ctx.numa_node = msl->socket_id;
>>>>>        rc = ena_com_create_io_queue(ena_dev, &ctx);
>>>>>        if (rc) {
>>>>>
>>>>
>>>> Hi Anatoly,
>>>>
>>>> I'm not sure why the previous maintainers implemented this that way, I
>>>> can only guess. I think that they were assuming, that each queue will
>>>> be assigned to the lcore which is equal to ring id. They probably also
>>>> misunderstood how the memzones are working and they thought that each
>>>> lcore is having assigned only one memzone which is being mapped 1 to 1.
>>>>
>>>> They wanted to prevent cross NUMA data acces, when the CPU is
>>>> operating in the different NUMA zone and the IO queues memory resides
>>>> in the other. I think that above solution won't prevent that neither,
>>>> as you are using ring address, which is being allocated together with
>>>> struct ena_adapter (it is just an array), so it will probably reside
>>>> in the single numa zone.
>>>>
>>>> I'm currently thinking on solution that could help us to determine on
>>>> which numa zone the queue descriptors will be allocated and on which
>>>> the lcore assigned to the queue will be working, but have no any ideas
>>>> for now :)
>>>>
>>>> Anyway, your fix won't break anything, as the previous solution wasn't
>>>> working as it was supposed to work, so before I will fix that, we can
>>>> keep that patch to prevent direct usage of the memzone.
>>>>
>>>> Thanks,
>>>> Michal
>>>
>>> After investigation I think that we should use socket_id provided by the
>>> tx/rx queue setup functions.
>>> Could you, please, abandon this patch? I will send the proper fix soon.
>>>
>>
>> I can't really "abandon" it as it will break ENA compilation once the
>> structure is hidden in the last patch. What i can do is wait for you to
>> submit your patch, and either rebase my patchset on top of it, or
>> (better) include it in the patchset itself.
> 
> Ok, I've just uploaded the patch (second version has fixed commit
> log), you can find it below
> https://patches.dpdk.org/patch/54352/
> 
> I'm fine with including the patch into this patchset.
> 

Thanks for your quick implementation!

I'll include it in the inevitable v2.

>>
>>> Thanks,
>>> Michal
>>>
>>
>>
>> --
>> Thanks,
>> Anatoly
> 


-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 00/14] Make shared memory config non-public
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (25 preceding siblings ...)
  2019-05-29 20:11 ` [dpdk-dev] [PATCH 00/25] Make shared memory config non-public David Marchand
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
                     ` (14 more replies)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 01/14] eal: add API to lock/unlock memory hotplug Anatoly Burakov
                   ` (13 subsequent siblings)
  40 siblings, 15 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

This patchset removes the shared memory config from public
API, and replaces all usages of said config with new API
calls.

A lot of the patchset is a search-and-replace job and should
be pretty easy to review. The rest are pretty trivial EAL
changes.

This patchset depends on FreeBSD fixes patchset:

http://patches.dpdk.org/project/dpdk/list/?series=5161

v2:
- Collapsed all changes into fewer patches
- Addressed review comments
- Created a new file to store the code
- Changed namespace to "rte_mcfg_"
- Added some unification around config init
- Removed "packed" attribute from mem config
- Removed unnecessary inlining
- Added a check to explicitly forbid running multiprocess
  applications that differ in their DPDK versions

Anatoly Burakov (14):
  eal: add API to lock/unlock memory hotplug
  drivers: use new memory locking API
  lib: use new memory locking API
  eal: add EAL tailq list lock/unlock API
  lib: use new tailq locking API
  eal: add new API to lock/unlock mempool list
  mempool: use new mempool list locking API
  eal: remove unused macros
  eal: hide shared memory config
  eal: remove packed attribute from mcfg structure
  eal: uninline wait for mcfg complete function
  eal: unify and move mcfg complete function
  eal: unify internal config initialization
  eal: prevent different primary/secondary process versions

 app/test/test_memzone.c                       |   1 +
 app/test/test_tailq.c                         |   1 +
 doc/guides/rel_notes/deprecation.rst          |   3 -
 doc/guides/rel_notes/release_19_08.rst        |   8 +-
 drivers/bus/fslmc/fslmc_vfio.c                |   8 +-
 drivers/bus/pci/linux/pci_vfio.c              |   1 +
 drivers/net/mlx4/mlx4_mr.c                    |  11 +-
 drivers/net/mlx5/mlx5_mr.c                    |  11 +-
 .../net/virtio/virtio_user/virtio_user_dev.c  |   7 +-
 lib/librte_acl/rte_acl.c                      |  20 +--
 lib/librte_distributor/rte_distributor.c      |   5 +-
 lib/librte_distributor/rte_distributor_v20.c  |   5 +-
 lib/librte_eal/common/eal_common_mcfg.c       | 149 ++++++++++++++++++
 lib/librte_eal/common/eal_common_memory.c     |  44 +++---
 lib/librte_eal/common/eal_common_memzone.c    |   1 +
 lib/librte_eal/common/eal_common_tailqs.c     |   5 +-
 lib/librte_eal/common/eal_memcfg.h            |  94 +++++++++++
 lib/librte_eal/common/include/rte_eal.h       |  10 --
 .../common/include/rte_eal_memconfig.h        | 143 +++++++++--------
 lib/librte_eal/common/malloc_heap.c           |  16 +-
 lib/librte_eal/common/malloc_mp.c             |   1 +
 lib/librte_eal/common/meson.build             |   1 +
 lib/librte_eal/common/rte_malloc.c            |  33 ++--
 lib/librte_eal/freebsd/eal/Makefile           |   3 +-
 lib/librte_eal/freebsd/eal/eal.c              |  31 ++--
 lib/librte_eal/freebsd/eal/eal_memory.c       |   1 +
 lib/librte_eal/linux/eal/Makefile             |   3 +-
 lib/librte_eal/linux/eal/eal.c                |  51 ++----
 lib/librte_eal/linux/eal/eal_memalloc.c       |   1 +
 lib/librte_eal/linux/eal/eal_memory.c         |   1 +
 lib/librte_eal/linux/eal/eal_vfio.c           |  17 +-
 lib/librte_eal/meson.build                    |   2 +-
 lib/librte_eal/rte_eal_version.map            |  12 ++
 lib/librte_efd/rte_efd.c                      |  15 +-
 lib/librte_eventdev/rte_event_ring.c          |  16 +-
 lib/librte_hash/rte_cuckoo_hash.c             |  17 +-
 lib/librte_hash/rte_fbk_hash.c                |  15 +-
 lib/librte_kni/rte_kni.c                      |  16 +-
 lib/librte_lpm/rte_lpm.c                      |  25 +--
 lib/librte_lpm/rte_lpm6.c                     |  15 +-
 lib/librte_member/rte_member.c                |  17 +-
 lib/librte_mempool/rte_mempool.c              |  27 ++--
 lib/librte_reorder/rte_reorder.c              |  15 +-
 lib/librte_ring/rte_ring.c                    |  19 +--
 lib/librte_stack/rte_stack.c                  |  18 +--
 45 files changed, 583 insertions(+), 332 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_mcfg.c
 create mode 100644 lib/librte_eal/common/eal_memcfg.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 01/14] eal: add API to lock/unlock memory hotplug
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (26 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 02/14] drivers: use new memory locking API Anatoly Burakov
                   ` (12 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, david.marchand, thomas, stephen

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 <anatoly.burakov@intel.com>
---
 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 <rte_config.h>
+#include <rte_eal_memconfig.h>
+
+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

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 02/14] drivers: use new memory locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (27 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 01/14] eal: add API to lock/unlock memory hotplug Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-27  9:24   ` Hemant Agrawal
  2019-06-28 15:21   ` Yongseok Koh
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 03/14] lib: " Anatoly Burakov
                   ` (11 subsequent siblings)
  40 siblings, 2 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev
  Cc: Hemant Agrawal, Shreyansh Jain, Matan Azrad, Shahaf Shuler,
	Yongseok Koh, Maxime Coquelin, Tiwei Bie, Zhihong Wang,
	david.marchand, thomas, stephen

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/bus/fslmc/fslmc_vfio.c                   |  8 +++-----
 drivers/net/mlx4/mlx4_mr.c                       | 11 +++++------
 drivers/net/mlx5/mlx5_mr.c                       | 11 +++++------
 drivers/net/virtio/virtio_user/virtio_user_dev.c |  7 +++----
 4 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 1aae56fa9..44e4fa6e2 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -347,14 +347,12 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,
 int rte_fslmc_vfio_dmamap(void)
 {
 	int i = 0, ret;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 
 	/* Lock before parsing and registering callback to memory subsystem */
-	rte_rwlock_read_lock(mem_lock);
+	rte_mcfg_mem_read_lock();
 
 	if (rte_memseg_walk(fslmc_dmamap_seg, &i) < 0) {
-		rte_rwlock_read_unlock(mem_lock);
+		rte_mcfg_mem_read_unlock();
 		return -1;
 	}
 
@@ -378,7 +376,7 @@ int rte_fslmc_vfio_dmamap(void)
 	/* Existing segments have been mapped and memory callback for hotplug
 	 * has been installed.
 	 */
-	rte_rwlock_read_unlock(mem_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return 0;
 }
diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
index 48d458ad4..80827ce75 100644
--- a/drivers/net/mlx4/mlx4_mr.c
+++ b/drivers/net/mlx4/mlx4_mr.c
@@ -593,7 +593,6 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		       uintptr_t addr)
 {
 	struct mlx4_priv *priv = dev->data->dev_private;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	const struct rte_memseg_list *msl;
 	const struct rte_memseg *ms;
 	struct mlx4_mr *mr = NULL;
@@ -696,7 +695,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	 * just single page. If not, go on with the big chunk atomically from
 	 * here.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	data_re = data;
 	if (len > msl->page_sz &&
 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
@@ -714,7 +713,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		 */
 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
 		data.end = data.start + msl->page_sz;
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		mr_free(mr);
 		goto alloc_resources;
 	}
@@ -734,7 +733,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		DEBUG("port %u found MR for %p on final lookup, abort",
 		      dev->data->port_id, (void *)addr);
 		rte_rwlock_write_unlock(&priv->mr.rwlock);
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		/*
 		 * Must be unlocked before calling rte_free() because
 		 * mlx4_mr_mem_event_free_cb() can be called inside.
@@ -802,12 +801,12 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	/* Lookup can't fail. */
 	assert(entry->lkey != UINT32_MAX);
 	rte_rwlock_write_unlock(&priv->mr.rwlock);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return entry->lkey;
 err_mrlock:
 	rte_rwlock_write_unlock(&priv->mr.rwlock);
 err_memlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 err_nolock:
 	/*
 	 * In case of error, as this can be called in a datapath, a warning
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 66e8e874e..872d0591e 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -580,7 +580,6 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_ibv_shared *sh = priv->sh;
 	struct mlx5_dev_config *config = &priv->config;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	const struct rte_memseg_list *msl;
 	const struct rte_memseg *ms;
 	struct mlx5_mr *mr = NULL;
@@ -684,7 +683,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	 * just single page. If not, go on with the big chunk atomically from
 	 * here.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	data_re = data;
 	if (len > msl->page_sz &&
 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
@@ -702,7 +701,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 		 */
 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
 		data.end = data.start + msl->page_sz;
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		mr_free(mr);
 		goto alloc_resources;
 	}
@@ -722,7 +721,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 		DEBUG("port %u found MR for %p on final lookup, abort",
 		      dev->data->port_id, (void *)addr);
 		rte_rwlock_write_unlock(&sh->mr.rwlock);
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		/*
 		 * Must be unlocked before calling rte_free() because
 		 * mlx5_mr_mem_event_free_cb() can be called inside.
@@ -790,12 +789,12 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	/* Lookup can't fail. */
 	assert(entry->lkey != UINT32_MAX);
 	rte_rwlock_write_unlock(&sh->mr.rwlock);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return entry->lkey;
 err_mrlock:
 	rte_rwlock_write_unlock(&sh->mr.rwlock);
 err_memlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 err_nolock:
 	/*
 	 * In case of error, as this can be called in a datapath, a warning
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index e743695e4..c3ab9a21d 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -125,7 +125,6 @@ is_vhost_user_by_type(const char *path)
 int
 virtio_user_start_device(struct virtio_user_dev *dev)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	uint64_t features;
 	int ret;
 
@@ -142,7 +141,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 	 * replaced when we get proper supports from the
 	 * memory subsystem in the future.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	pthread_mutex_lock(&dev->mutex);
 
 	if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0)
@@ -180,12 +179,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 
 	dev->started = true;
 	pthread_mutex_unlock(&dev->mutex);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return 0;
 error:
 	pthread_mutex_unlock(&dev->mutex);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	/* TODO: free resource here or caller to check */
 	return -1;
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 03/14] lib: use new memory locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (28 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 02/14] drivers: use new memory locking API Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 04/14] eal: add EAL tailq list lock/unlock API Anatoly Burakov
                   ` (10 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_memory.c | 43 ++++++++++-------------
 lib/librte_eal/common/malloc_heap.c       | 14 ++++----
 lib/librte_eal/common/rte_malloc.c        | 32 ++++++++---------
 lib/librte_eal/linux/eal/eal_vfio.c       | 16 ++++-----
 4 files changed, 44 insertions(+), 61 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 5ae8d0124..e73a413cc 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -596,13 +596,12 @@ rte_memseg_contig_walk_thread_unsafe(rte_memseg_contig_walk_t func, void *arg)
 int __rte_experimental
 rte_memseg_contig_walk(rte_memseg_contig_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_contig_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -638,13 +637,12 @@ rte_memseg_walk_thread_unsafe(rte_memseg_walk_t func, void *arg)
 int __rte_experimental
 rte_memseg_walk(rte_memseg_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -671,13 +669,12 @@ rte_memseg_list_walk_thread_unsafe(rte_memseg_list_walk_t func, void *arg)
 int __rte_experimental
 rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_list_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -727,12 +724,11 @@ rte_memseg_get_fd_thread_unsafe(const struct rte_memseg *ms)
 int __rte_experimental
 rte_memseg_get_fd(const struct rte_memseg *ms)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_get_fd_thread_unsafe(ms);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -783,12 +779,11 @@ rte_memseg_get_fd_offset_thread_unsafe(const struct rte_memseg *ms,
 int __rte_experimental
 rte_memseg_get_fd_offset(const struct rte_memseg *ms, size_t *offset)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_get_fd_offset_thread_unsafe(ms, offset);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -809,7 +804,7 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* make sure the segment doesn't already exist */
 	if (malloc_heap_find_external_seg(va_addr, len) != NULL) {
@@ -838,14 +833,13 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
 	/* memseg list successfully created - increment next socket ID */
 	mcfg->next_socket_id++;
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
 int __rte_experimental
 rte_extmem_unregister(void *va_addr, size_t len)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct rte_memseg_list *msl;
 	int ret = 0;
 
@@ -853,7 +847,7 @@ rte_extmem_unregister(void *va_addr, size_t len)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our segment */
 	msl = malloc_heap_find_external_seg(va_addr, len);
@@ -865,14 +859,13 @@ rte_extmem_unregister(void *va_addr, size_t len)
 
 	ret = malloc_heap_destroy_external_seg(msl);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
 static int
 sync_memory(void *va_addr, size_t len, bool attach)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct rte_memseg_list *msl;
 	int ret = 0;
 
@@ -880,7 +873,7 @@ sync_memory(void *va_addr, size_t len, bool attach)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our segment */
 	msl = malloc_heap_find_external_seg(va_addr, len);
@@ -895,7 +888,7 @@ sync_memory(void *va_addr, size_t len, bool attach)
 		ret = rte_fbarray_detach(&msl->memseg_arr);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
@@ -923,7 +916,7 @@ rte_eal_memory_init(void)
 		return -1;
 
 	/* lock mem hotplug here, to prevent races while we init */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 
 	if (rte_eal_memseg_init() < 0)
 		goto fail;
@@ -942,6 +935,6 @@ rte_eal_memory_init(void)
 
 	return 0;
 fail:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return -1;
 }
diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index f9235932e..f1d31de0d 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -485,10 +485,9 @@ try_expand_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,
 		int socket, unsigned int flags, size_t align, size_t bound,
 		bool contig)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		ret = try_expand_heap_primary(heap, pg_sz, elt_size, socket,
@@ -498,7 +497,7 @@ try_expand_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,
 				flags, align, bound, contig);
 	}
 
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
@@ -821,7 +820,6 @@ malloc_heap_free_pages(void *aligned_start, size_t aligned_len)
 int
 malloc_heap_free(struct malloc_elem *elem)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap;
 	void *start, *aligned_start, *end, *aligned_end;
 	size_t len, aligned_len, page_sz;
@@ -935,7 +933,7 @@ malloc_heap_free(struct malloc_elem *elem)
 
 	/* now we can finally free us some pages */
 
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/*
 	 * we allow secondary processes to clear the heap of this allocated
@@ -990,7 +988,7 @@ malloc_heap_free(struct malloc_elem *elem)
 	RTE_LOG(DEBUG, EAL, "Heap on socket %d was shrunk by %zdMB\n",
 		msl->socket_id, aligned_len >> 20ULL);
 
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 free_unlock:
 	rte_spinlock_unlock(&(heap->lock));
 	return ret;
@@ -1344,7 +1342,7 @@ rte_eal_malloc_heap_init(void)
 
 	if (register_mp_requests()) {
 		RTE_LOG(ERR, EAL, "Couldn't register malloc multiprocess actions\n");
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		return -1;
 	}
 
@@ -1352,7 +1350,7 @@ rte_eal_malloc_heap_init(void)
 	 * even come before primary itself is fully initialized, and secondaries
 	 * do not need to initialize the heap.
 	 */
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	/* secondary process does not need to initialize anything */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index 54792ea5b..98e1bdd07 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -223,7 +223,7 @@ rte_malloc_heap_get_socket(const char *name)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	for (idx = 0; idx < RTE_MAX_HEAPS; idx++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[idx];
 
@@ -239,7 +239,7 @@ rte_malloc_heap_get_socket(const char *name)
 		rte_errno = ENOENT;
 		ret = -1;
 	}
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -254,7 +254,7 @@ rte_malloc_heap_socket_is_external(int socket_id)
 	if (socket_id == SOCKET_ID_ANY)
 		return 0;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	for (idx = 0; idx < RTE_MAX_HEAPS; idx++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[idx];
 
@@ -264,7 +264,7 @@ rte_malloc_heap_socket_is_external(int socket_id)
 			break;
 		}
 	}
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -352,7 +352,6 @@ int
 rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 		rte_iova_t iova_addrs[], unsigned int n_pages, size_t page_sz)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	unsigned int n;
@@ -369,7 +368,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our heap */
 	heap = find_named_heap(heap_name);
@@ -398,7 +397,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 	rte_spinlock_unlock(&heap->lock);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -406,7 +405,6 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 int
 rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	int ret;
@@ -418,7 +416,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 	/* find our heap */
 	heap = find_named_heap(heap_name);
 	if (heap == NULL) {
@@ -448,7 +446,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 	ret = malloc_heap_destroy_external_seg(msl);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -456,7 +454,6 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 static int
 sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	int ret;
@@ -468,7 +465,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 
 	/* find our heap */
 	heap = find_named_heap(heap_name);
@@ -516,7 +513,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 		}
 	}
 unlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return ret;
 }
 
@@ -549,7 +546,7 @@ rte_malloc_heap_create(const char *heap_name)
 	/* check if there is space in the heap list, or if heap with this name
 	 * already exists.
 	 */
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	for (i = 0; i < RTE_MAX_HEAPS; i++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[i];
@@ -578,7 +575,7 @@ rte_malloc_heap_create(const char *heap_name)
 	/* we're sure that we can create a new heap, so do it */
 	ret = malloc_heap_create(heap, heap_name);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -586,7 +583,6 @@ rte_malloc_heap_create(const char *heap_name)
 int
 rte_malloc_heap_destroy(const char *heap_name)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	int ret;
 
@@ -597,7 +593,7 @@ rte_malloc_heap_destroy(const char *heap_name)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* start from non-socket heaps */
 	heap = find_named_heap(heap_name);
@@ -621,7 +617,7 @@ rte_malloc_heap_destroy(const char *heap_name)
 	if (ret < 0)
 		rte_spinlock_unlock(&heap->lock);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index 6892a2c14..924cba526 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -635,8 +635,6 @@ int
 rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 		int *vfio_dev_fd, struct vfio_device_info *device_info)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 	struct vfio_group_status group_status = {
 			.argsz = sizeof(group_status)
 	};
@@ -739,7 +737,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 			/* lock memory hotplug before mapping and release it
 			 * after registering callback, to prevent races
 			 */
-			rte_rwlock_read_lock(mem_lock);
+			rte_mcfg_mem_read_lock();
 			if (vfio_cfg == default_vfio_cfg)
 				ret = t->dma_map_func(vfio_container_fd);
 			else
@@ -750,7 +748,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 					dev_addr, errno, strerror(errno));
 				close(vfio_group_fd);
 				rte_vfio_clear_group(vfio_group_fd);
-				rte_rwlock_read_unlock(mem_lock);
+				rte_mcfg_mem_read_unlock();
 				return -1;
 			}
 
@@ -781,7 +779,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 							map->len);
 					rte_spinlock_recursive_unlock(
 							&user_mem_maps->lock);
-					rte_rwlock_read_unlock(mem_lock);
+					rte_mcfg_mem_read_unlock();
 					return -1;
 				}
 			}
@@ -795,7 +793,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 			else
 				ret = 0;
 			/* unlock memory hotplug */
-			rte_rwlock_read_unlock(mem_lock);
+			rte_mcfg_mem_read_unlock();
 
 			if (ret && rte_errno != ENOTSUP) {
 				RTE_LOG(ERR, EAL, "Could not install memory event callback for VFIO\n");
@@ -862,8 +860,6 @@ int
 rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 		    int vfio_dev_fd)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 	struct vfio_group_status group_status = {
 			.argsz = sizeof(group_status)
 	};
@@ -876,7 +872,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 	 * VFIO device, because this might be the last device and we might need
 	 * to unregister the callback.
 	 */
-	rte_rwlock_read_lock(mem_lock);
+	rte_mcfg_mem_read_lock();
 
 	/* get group number */
 	ret = rte_vfio_get_group_num(sysfs_base, dev_addr, &iommu_group_num);
@@ -947,7 +943,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 	ret = 0;
 
 out:
-	rte_rwlock_read_unlock(mem_lock);
+	rte_mcfg_mem_read_unlock();
 	return ret;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 04/14] eal: add EAL tailq list lock/unlock API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (29 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 03/14] lib: " Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 05/14] lib: use new tailq locking API Anatoly Burakov
                   ` (9 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

Currently, locking/unlocking the TAILQ list requires direct
access to the shared memory config. Add an API to do the same.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.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_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 985d36cc2..05167e4dc 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -32,3 +32,31 @@ 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);
 }
+
+void
+rte_mcfg_tailq_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->qlock);
+}
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index a554518ef..240fa150b 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -124,6 +124,30 @@ rte_mcfg_mem_write_lock(void);
 void
 rte_mcfg_mem_write_unlock(void);
 
+/**
+ * Lock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_mcfg_tailq_read_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_mcfg_tailq_read_unlock(void);
+
+/**
+ * Lock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_mcfg_tailq_write_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_mcfg_tailq_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 faad879db..ebdcdf269 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -296,6 +296,10 @@ DPDK_19.08 {
 	rte_mcfg_mem_read_unlock;
 	rte_mcfg_mem_write_lock;
 	rte_mcfg_mem_write_unlock;
+	rte_mcfg_tailq_read_lock;
+	rte_mcfg_tailq_read_unlock;
+	rte_mcfg_tailq_write_lock;
+	rte_mcfg_tailq_write_unlock;
 
 } DPDK_19.05;
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 05/14] lib: use new tailq locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (30 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 04/14] eal: add EAL tailq list lock/unlock API Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 06/14] eal: add new API to lock/unlock mempool list Anatoly Burakov
                   ` (8 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev
  Cc: Konstantin Ananyev, David Hunt, Byron Marohn,
	Pablo de Lara Guarch, Jerin Jacob, Yipeng Wang, Sameh Gobriel,
	Bruce Richardson, Ferruh Yigit, Vladimir Medvedkin, Olivier Matz,
	Andrew Rybchenko, Reshma Pattan, Gage Eads, david.marchand,
	thomas, stephen

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_acl/rte_acl.c                     | 18 +++++++--------
 lib/librte_distributor/rte_distributor.c     |  4 ++--
 lib/librte_distributor/rte_distributor_v20.c |  4 ++--
 lib/librte_eal/common/eal_common_tailqs.c    |  4 ++--
 lib/librte_efd/rte_efd.c                     | 14 ++++++------
 lib/librte_eventdev/rte_event_ring.c         | 16 ++++++-------
 lib/librte_hash/rte_cuckoo_hash.c            | 16 ++++++-------
 lib/librte_hash/rte_fbk_hash.c               | 14 ++++++------
 lib/librte_kni/rte_kni.c                     | 16 ++++++-------
 lib/librte_lpm/rte_lpm.c                     | 24 ++++++++++----------
 lib/librte_lpm/rte_lpm6.c                    | 14 ++++++------
 lib/librte_member/rte_member.c               | 16 ++++++-------
 lib/librte_mempool/rte_mempool.c             |  8 +++----
 lib/librte_reorder/rte_reorder.c             | 14 ++++++------
 lib/librte_ring/rte_ring.c                   | 18 +++++++--------
 lib/librte_stack/rte_stack.c                 | 18 +++++++--------
 16 files changed, 109 insertions(+), 109 deletions(-)

diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index fd5bd5e4e..7ff11d25f 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -156,13 +156,13 @@ rte_acl_find_existing(const char *name)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, acl_list, next) {
 		ctx = (struct rte_acl_ctx *) te->data;
 		if (strncmp(name, ctx->name, sizeof(ctx->name)) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -182,7 +182,7 @@ rte_acl_free(struct rte_acl_ctx *ctx)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, acl_list, next) {
@@ -190,13 +190,13 @@ rte_acl_free(struct rte_acl_ctx *ctx)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(acl_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(ctx->mem);
 	rte_free(ctx);
@@ -226,7 +226,7 @@ rte_acl_create(const struct rte_acl_param *param)
 	sz = sizeof(*ctx) + param->max_rule_num * param->rule_size;
 
 	/* get EAL TAILQ lock. */
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* if we already have one with that name */
 	TAILQ_FOREACH(te, acl_list, next) {
@@ -268,7 +268,7 @@ rte_acl_create(const struct rte_acl_param *param)
 	}
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return ctx;
 }
 
@@ -377,10 +377,10 @@ rte_acl_list_dump(void)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, acl_list, next) {
 		ctx = (struct rte_acl_ctx *) te->data;
 		rte_acl_dump(ctx);
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 }
diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 208abfb1d..9eb78b330 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -645,9 +645,9 @@ rte_distributor_create_v1705(const char *name,
 					  rte_dist_burst_list);
 
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(dist_burst_list, d, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return d;
 }
diff --git a/lib/librte_distributor/rte_distributor_v20.c b/lib/librte_distributor/rte_distributor_v20.c
index cd5940713..1fc03b971 100644
--- a/lib/librte_distributor/rte_distributor_v20.c
+++ b/lib/librte_distributor/rte_distributor_v20.c
@@ -392,9 +392,9 @@ rte_distributor_create_v20(const char *name,
 	distributor_list = RTE_TAILQ_CAST(rte_distributor_tailq.head,
 					  rte_distributor_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(distributor_list, d, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return d;
 }
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index ca2a7d32a..dc2c13caa 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -58,7 +58,7 @@ rte_dump_tailq(FILE *f)
 
 	mcfg = rte_eal_get_configuration()->mem_config;
 
-	rte_rwlock_read_lock(&mcfg->qlock);
+	rte_mcfg_tailq_read_lock();
 	for (i = 0; i < RTE_MAX_TAILQ; i++) {
 		const struct rte_tailq_head *tailq = &mcfg->tailq_head[i];
 		const struct rte_tailq_entry_head *head = &tailq->tailq_head;
@@ -66,7 +66,7 @@ rte_dump_tailq(FILE *f)
 		fprintf(f, "Tailq %u: qname:<%s>, tqh_first:%p, tqh_last:%p\n",
 			i, tailq->name, head->tqh_first, head->tqh_last);
 	}
-	rte_rwlock_read_unlock(&mcfg->qlock);
+	rte_mcfg_tailq_read_unlock();
 }
 
 static struct rte_tailq_head *
diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index 14e493bc3..b808ce99f 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -532,7 +532,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	num_chunks_shift = rte_bsf32(num_chunks);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/*
 	 * Guarantee there's no existing: this is normally already checked
@@ -685,7 +685,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	te->data = (void *) table;
 	TAILQ_INSERT_TAIL(efd_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	snprintf(ring_name, sizeof(ring_name), "HT_%s", table->name);
 	/* Create ring (Dummy slot index is not enqueued) */
@@ -705,7 +705,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	return table;
 
 error_unlock_exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_efd_free(table);
 
 	return NULL;
@@ -720,7 +720,7 @@ rte_efd_find_existing(const char *name)
 
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, efd_list, next)
 	{
@@ -728,7 +728,7 @@ rte_efd_find_existing(const char *name)
 		if (strncmp(name, table->name, RTE_EFD_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -751,7 +751,7 @@ rte_efd_free(struct rte_efd_table *table)
 		rte_free(table->chunks[socket_id]);
 
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH_SAFE(te, efd_list, next, temp) {
 		if (te->data == (void *) table) {
@@ -761,7 +761,7 @@ rte_efd_free(struct rte_efd_table *table)
 		}
 	}
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_ring_free(table->free_slots);
 	rte_free(table->offline_chunks);
 	rte_free(table->keys);
diff --git a/lib/librte_eventdev/rte_event_ring.c b/lib/librte_eventdev/rte_event_ring.c
index 16d02a953..50190de01 100644
--- a/lib/librte_eventdev/rte_event_ring.c
+++ b/lib/librte_eventdev/rte_event_ring.c
@@ -72,7 +72,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/*
 	 * reserve a memory zone for this ring. If we can't get rte_config or
@@ -89,7 +89,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 			if (rte_memzone_free(mz) != 0)
 				RTE_LOG(ERR, RING, "Cannot free memzone\n");
 			rte_free(te);
-			rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+			rte_mcfg_tailq_write_unlock();
 			return NULL;
 		}
 
@@ -102,7 +102,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return r;
 }
@@ -118,7 +118,7 @@ rte_event_ring_lookup(const char *name)
 	ring_list = RTE_TAILQ_CAST(rte_event_ring_tailq.head,
 			rte_event_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		r = (struct rte_event_ring *) te->data;
@@ -126,7 +126,7 @@ rte_event_ring_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -163,7 +163,7 @@ rte_event_ring_free(struct rte_event_ring *r)
 
 	ring_list = RTE_TAILQ_CAST(rte_event_ring_tailq.head,
 			rte_event_ring_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, ring_list, next) {
@@ -172,13 +172,13 @@ rte_event_ring_free(struct rte_event_ring *r)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(ring_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 }
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 953928f27..865c744d9 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -52,13 +52,13 @@ rte_hash_find_existing(const char *name)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, hash_list, next) {
 		h = (struct rte_hash *) te->data;
 		if (strncmp(name, h->name, RTE_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -239,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	snprintf(hash_name, sizeof(hash_name), "HT_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing: this is normally already checked
 	 * by ring creation above */
@@ -437,11 +437,11 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	te->data = (void *) h;
 	TAILQ_INSERT_TAIL(hash_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return h;
 err_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 err:
 	rte_ring_free(r);
 	rte_ring_free(r_ext);
@@ -466,7 +466,7 @@ rte_hash_free(struct rte_hash *h)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, hash_list, next) {
@@ -475,13 +475,13 @@ rte_hash_free(struct rte_hash *h)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	if (h->use_local_cache)
 		rte_free(h->local_free_slots);
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index 9360f7981..db118c930 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -50,13 +50,13 @@ rte_fbk_hash_find_existing(const char *name)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
 		h = (struct rte_fbk_hash_table *) te->data;
 		if (strncmp(name, h->name, RTE_FBK_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 	if (te == NULL) {
 		rte_errno = ENOENT;
 		return NULL;
@@ -103,7 +103,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 
 	snprintf(hash_name, sizeof(hash_name), "FBK_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -165,7 +165,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 	TAILQ_INSERT_TAIL(fbk_hash_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return ht;
 }
@@ -188,7 +188,7 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -197,13 +197,13 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(fbk_hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(ht);
 	rte_free(te);
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index e29d0cc7d..f6684851c 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -214,7 +214,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	kni = __rte_kni_get(conf->name);
 	if (kni != NULL) {
@@ -304,7 +304,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 	TAILQ_INSERT_TAIL(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	/* Allocate mbufs and then put them into alloc_q */
 	kni_allocate_mbufs(kni);
@@ -318,7 +318,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 kni_fail:
 	rte_free(te);
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return NULL;
 }
@@ -381,7 +381,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, kni_list, next) {
 		if (te->data == kni)
@@ -399,7 +399,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	TAILQ_REMOVE(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	/* mbufs in all fifo should be released, except request/response */
 
@@ -423,7 +423,7 @@ rte_kni_release(struct rte_kni *kni)
 	return 0;
 
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return -1;
 }
@@ -640,11 +640,11 @@ rte_kni_get(const char *name)
 	if (name == NULL || name[0] == '\0')
 		return NULL;
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	kni = __rte_kni_get(name);
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	return kni;
 }
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index 6b7b28a2e..b91f74216 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -97,13 +97,13 @@ rte_lpm_find_existing_v20(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -123,13 +123,13 @@ rte_lpm_find_existing_v1604(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -170,7 +170,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	/* Determine the amount of memory to allocate. */
 	mem_size = sizeof(*lpm) + (sizeof(lpm->rules_tbl[0]) * max_rules);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -212,7 +212,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return lpm;
 }
@@ -247,7 +247,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	tbl8s_size = (sizeof(struct rte_lpm_tbl_entry) *
 			RTE_LPM_TBL8_GROUP_NUM_ENTRIES * config->number_tbl8s);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -315,7 +315,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return lpm;
 }
@@ -339,7 +339,7 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -349,7 +349,7 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm);
 	rte_free(te);
@@ -368,7 +368,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -378,7 +378,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm->tbl8);
 	rte_free(lpm->rules_tbl);
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index a91803113..5af74a539 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -316,7 +316,7 @@ rte_lpm6_create(const char *name, int socket_id,
 	mem_size = sizeof(*lpm) + (sizeof(lpm->tbl8[0]) *
 			RTE_LPM6_TBL8_GROUP_NUM_ENTRIES * config->number_tbl8s);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* Guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -363,11 +363,11 @@ rte_lpm6_create(const char *name, int socket_id,
 	te->data = (void *) lpm;
 
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return lpm;
 
 fail:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 fail_wo_unlock:
 	rte_free(tbl8_hdrs);
@@ -389,13 +389,13 @@ rte_lpm6_find_existing(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = (struct rte_lpm6 *) te->data;
 		if (strncmp(name, l->name, RTE_LPM6_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -420,7 +420,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -431,7 +431,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm->tbl8_hdrs);
 	rte_free(lpm->tbl8_pool);
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index fd228f4ba..efed28dd9 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -32,13 +32,13 @@ rte_member_find_existing(const char *name)
 
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, member_list, next) {
 		setsum = (struct rte_member_setsum *) te->data;
 		if (strncmp(name, setsum->name, RTE_MEMBER_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -56,17 +56,17 @@ rte_member_free(struct rte_member_setsum *setsum)
 	if (setsum == NULL)
 		return;
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_FOREACH(te, member_list, next) {
 		if (te->data == (void *)setsum)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 	TAILQ_REMOVE(member_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	switch (setsum->type) {
 	case RTE_MEMBER_TYPE_HT:
@@ -105,7 +105,7 @@ rte_member_create(const struct rte_member_parameters *params)
 
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, member_list, next) {
 		setsum = te->data;
@@ -159,13 +159,13 @@ rte_member_create(const struct rte_member_parameters *params)
 
 	te->data = (void *)setsum;
 	TAILQ_INSERT_TAIL(member_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return setsum;
 
 error_unlock_exit:
 	rte_free(te);
 	rte_free(setsum);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return NULL;
 }
 
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 69bd2a65c..238287a01 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -711,7 +711,7 @@ rte_mempool_free(struct rte_mempool *mp)
 		return;
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, mempool_list, next) {
 		if (te->data == (void *)mp)
@@ -722,7 +722,7 @@ rte_mempool_free(struct rte_mempool *mp)
 		TAILQ_REMOVE(mempool_list, te, next);
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_mempool_free_memchunks(mp);
 	rte_mempool_ops_free(mp);
@@ -898,9 +898,9 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 
 	te->data = mp;
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(mempool_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
 
 	return mp;
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index 3a4a1b0a0..ae6e3f578 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -119,7 +119,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, reorder_list, next) {
@@ -152,7 +152,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 	}
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return b;
 }
 
@@ -193,7 +193,7 @@ rte_reorder_free(struct rte_reorder_buffer *b)
 
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, reorder_list, next) {
@@ -201,13 +201,13 @@ rte_reorder_free(struct rte_reorder_buffer *b)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(reorder_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_reorder_free_mbufs(b);
 
@@ -229,13 +229,13 @@ rte_reorder_find_existing(const char *name)
 
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, reorder_list, next) {
 		b = (struct rte_reorder_buffer *) te->data;
 		if (strncmp(name, b->name, RTE_REORDER_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index b89ecf999..9ea26a631 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -147,7 +147,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* reserve a memory zone for this ring. If we can't get rte_config or
 	 * we are secondary process, the memzone_reserve function will set
@@ -169,7 +169,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
 		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return r;
 }
@@ -200,7 +200,7 @@ rte_ring_free(struct rte_ring *r)
 	}
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, ring_list, next) {
@@ -209,13 +209,13 @@ rte_ring_free(struct rte_ring *r)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(ring_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 }
@@ -245,13 +245,13 @@ rte_ring_list_dump(FILE *f)
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		rte_ring_dump(f, (struct rte_ring *) te->data);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 }
 
 /* search a ring from its name */
@@ -264,7 +264,7 @@ rte_ring_lookup(const char *name)
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		r = (struct rte_ring *) te->data;
@@ -272,7 +272,7 @@ rte_ring_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index 60f63a65b..2cc7e8e16 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -84,13 +84,13 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	mz = rte_memzone_reserve_aligned(mz_name, sz, socket_id,
 					 0, __alignof__(*s));
 	if (mz == NULL) {
 		STACK_LOG_ERR("Cannot reserve stack memzone!\n");
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		rte_free(te);
 		return NULL;
 	}
@@ -102,7 +102,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 	/* Store the name for later lookups */
 	ret = strlcpy(s->name, name, sizeof(s->name));
 	if (ret < 0 || ret >= (int)sizeof(s->name)) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 
 		rte_errno = ENAMETOOLONG;
 		rte_free(te);
@@ -120,7 +120,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 
 	TAILQ_INSERT_TAIL(stack_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return s;
 }
@@ -135,7 +135,7 @@ rte_stack_free(struct rte_stack *s)
 		return;
 
 	stack_list = RTE_TAILQ_CAST(rte_stack_tailq.head, rte_stack_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, stack_list, next) {
@@ -144,13 +144,13 @@ rte_stack_free(struct rte_stack *s)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(stack_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 
@@ -171,7 +171,7 @@ rte_stack_lookup(const char *name)
 
 	stack_list = RTE_TAILQ_CAST(rte_stack_tailq.head, rte_stack_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, stack_list, next) {
 		r = (struct rte_stack *) te->data;
@@ -179,7 +179,7 @@ rte_stack_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 06/14] eal: add new API to lock/unlock mempool list
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (31 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 05/14] lib: use new tailq locking API Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 07/14] mempool: use new mempool list locking API Anatoly Burakov
                   ` (7 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

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 <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.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_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 05167e4dc..ba2bc37b7 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -60,3 +60,31 @@ rte_mcfg_tailq_write_unlock(void)
 	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	rte_rwlock_write_unlock(&mcfg->qlock);
 }
+
+void
+rte_mcfg_mempool_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->mplock);
+}
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index 240fa150b..58dcbb96d 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_mcfg_tailq_write_lock(void);
 void
 rte_mcfg_tailq_write_unlock(void);
 
+/**
+ * Lock the internal EAL Mempool list for shared access.
+ */
+void
+rte_mcfg_mempool_read_lock(void);
+
+/**
+ * Unlock the internal EAL Mempool list for shared access.
+ */
+void
+rte_mcfg_mempool_read_unlock(void);
+
+/**
+ * Lock the internal EAL Mempool list for exclusive access.
+ */
+void
+rte_mcfg_mempool_write_lock(void);
+
+/**
+ * Unlock the internal EAL Mempool list for exclusive access.
+ */
+void
+rte_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 ebdcdf269..c28951f65 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -296,6 +296,10 @@ DPDK_19.08 {
 	rte_mcfg_mem_read_unlock;
 	rte_mcfg_mem_write_lock;
 	rte_mcfg_mem_write_unlock;
+	rte_mcfg_mempool_read_lock;
+	rte_mcfg_mempool_read_unlock;
+	rte_mcfg_mempool_write_lock;
+	rte_mcfg_mempool_write_unlock;
 	rte_mcfg_tailq_read_lock;
 	rte_mcfg_tailq_read_unlock;
 	rte_mcfg_tailq_write_lock;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 07/14] mempool: use new mempool list locking API
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (32 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 06/14] eal: add new API to lock/unlock mempool list Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 08/14] eal: remove unused macros Anatoly Burakov
                   ` (6 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, Andrew Rybchenko, david.marchand, thomas, stephen

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 lib/librte_mempool/rte_mempool.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 238287a01..5c688d456 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -830,7 +830,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_lock();
 
 	/*
 	 * reserve a memory zone for this mempool: private data is
@@ -901,12 +901,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(mempool_list, te, next);
 	rte_mcfg_tailq_write_unlock();
-	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_unlock();
 
 	return mp;
 
 exit_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_unlock();
 	rte_free(te);
 	rte_mempool_free(mp);
 	return NULL;
@@ -1268,14 +1268,14 @@ rte_mempool_list_dump(FILE *f)
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH(te, mempool_list, next) {
 		mp = (struct rte_mempool *) te->data;
 		rte_mempool_dump(f, mp);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 }
 
 /* search a mempool from its name */
@@ -1288,7 +1288,7 @@ rte_mempool_lookup(const char *name)
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH(te, mempool_list, next) {
 		mp = (struct rte_mempool *) te->data;
@@ -1296,7 +1296,7 @@ rte_mempool_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -1315,11 +1315,11 @@ void rte_mempool_walk(void (*func)(struct rte_mempool *, void *),
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH_SAFE(te, mempool_list, next, tmp_te) {
 		(*func)((struct rte_mempool *) te->data, arg);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 08/14] eal: remove unused macros
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (33 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 07/14] mempool: use new mempool list locking API Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 09/14] eal: hide shared memory config Anatoly Burakov
                   ` (5 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

These macros are not used anymore and can be removed.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/include/rte_eal.h | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index cf701e177..7042672b0 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -449,16 +449,6 @@ typedef void	(*rte_usage_hook_t)(const char * prgname);
 rte_usage_hook_t
 rte_set_application_usage_hook(rte_usage_hook_t usage_func);
 
-/**
- * macro to get the lock of tailq in mem_config
- */
-#define RTE_EAL_TAILQ_RWLOCK         (&rte_eal_get_configuration()->mem_config->qlock)
-
-/**
- * macro to get the multiple lock of mempool shared by multiple-instance
- */
-#define RTE_EAL_MEMPOOL_RWLOCK            (&rte_eal_get_configuration()->mem_config->mplock)
-
 /**
  * Whether EAL is using huge pages (disabled by --no-huge option).
  * The no-huge mode cannot be used with UIO poll-mode drivers like igb/ixgbe.
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 09/14] eal: hide shared memory config
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (34 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 08/14] eal: remove unused macros Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 10/14] eal: remove packed attribute from mcfg structure Anatoly Burakov
                   ` (4 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev
  Cc: Neil Horman, John McNamara, Marko Kovacevic, Konstantin Ananyev,
	David Hunt, Bruce Richardson, Byron Marohn, Pablo de Lara Guarch,
	Yipeng Wang, Sameh Gobriel, Vladimir Medvedkin, Olivier Matz,
	Andrew Rybchenko, Reshma Pattan, david.marchand, thomas, stephen

Now that everything that has ever accessed the shared memory
config is doing so through the public API's, we can make it
internal. Since we're removing quite a few headers from
rte_eal_memconfig.h, we need to add them back in places
where this header is used.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 app/test/test_memzone.c                       |  1 +
 app/test/test_tailq.c                         |  1 +
 doc/guides/rel_notes/deprecation.rst          |  3 -
 doc/guides/rel_notes/release_19_08.rst        |  8 +-
 drivers/bus/pci/linux/pci_vfio.c              |  1 +
 lib/librte_acl/rte_acl.c                      |  2 +
 lib/librte_distributor/rte_distributor.c      |  1 +
 lib/librte_distributor/rte_distributor_v20.c  |  1 +
 lib/librte_eal/common/eal_common_mcfg.c       |  2 +
 lib/librte_eal/common/eal_common_memory.c     |  1 +
 lib/librte_eal/common/eal_common_memzone.c    |  1 +
 lib/librte_eal/common/eal_common_tailqs.c     |  1 +
 lib/librte_eal/common/eal_memcfg.h            | 79 +++++++++++++++++++
 .../common/include/rte_eal_memconfig.h        | 75 ++----------------
 lib/librte_eal/common/malloc_heap.c           |  2 +
 lib/librte_eal/common/malloc_mp.c             |  1 +
 lib/librte_eal/common/rte_malloc.c            |  1 +
 lib/librte_eal/freebsd/eal/Makefile           |  2 +-
 lib/librte_eal/freebsd/eal/eal_memory.c       |  1 +
 lib/librte_eal/linux/eal/Makefile             |  2 +-
 lib/librte_eal/linux/eal/eal.c                |  1 +
 lib/librte_eal/linux/eal/eal_memalloc.c       |  1 +
 lib/librte_eal/linux/eal/eal_memory.c         |  1 +
 lib/librte_eal/linux/eal/eal_vfio.c           |  1 +
 lib/librte_eal/meson.build                    |  2 +-
 lib/librte_efd/rte_efd.c                      |  1 +
 lib/librte_hash/rte_cuckoo_hash.c             |  1 +
 lib/librte_hash/rte_fbk_hash.c                |  1 +
 lib/librte_lpm/rte_lpm.c                      |  1 +
 lib/librte_lpm/rte_lpm6.c                     |  1 +
 lib/librte_member/rte_member.c                |  1 +
 lib/librte_mempool/rte_mempool.c              |  1 +
 lib/librte_reorder/rte_reorder.c              |  1 +
 lib/librte_ring/rte_ring.c                    |  1 +
 34 files changed, 125 insertions(+), 76 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_memcfg.h

diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index 9fe465e62..7501b63c5 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -19,6 +19,7 @@
 #include <rte_errno.h>
 #include <rte_malloc.h>
 #include "../../lib/librte_eal/common/malloc_elem.h"
+#include "../../lib/librte_eal/common/eal_memcfg.h"
 
 #include "test.h"
 
diff --git a/app/test/test_tailq.c b/app/test/test_tailq.c
index a4ecea2d8..7c9b69fdb 100644
--- a/app/test/test_tailq.c
+++ b/app/test/test_tailq.c
@@ -12,6 +12,7 @@
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
 #include <rte_string_fns.h>
+#include <rte_tailq.h>
 
 #include "test.h"
 
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index e2721fad6..583217da8 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -23,9 +23,6 @@ Deprecation Notices
 * eal: The function ``rte_eal_remote_launch`` will return new error codes
   after read or write error on the pipe, instead of calling ``rte_panic``.
 
-* eal: the ``rte_mem_config`` struct will be made private to remove it from the
-  externally visible ABI and allow it to be updated in the future.
-
 * eal: both declaring and identifying devices will be streamlined in v18.11.
   New functions will appear to query a specific port from buses, classes of
   device and device drivers. Device declaration will be made coherent with the
diff --git a/doc/guides/rel_notes/release_19_08.rst b/doc/guides/rel_notes/release_19_08.rst
index 3da266705..b6314431a 100644
--- a/doc/guides/rel_notes/release_19_08.rst
+++ b/doc/guides/rel_notes/release_19_08.rst
@@ -132,6 +132,10 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+* The ``rte_mem_config`` structure has been made private. The new accessor
+  ``rte_mcfg_*`` functions were introduced to provide replacement for direct
+  access to the shared mem config.
+
 * The network structures, definitions and functions have
   been prefixed by ``rte_`` to resolve conflicts with libc headers.
 
@@ -151,6 +155,8 @@ ABI Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+* The ``rte_mem_config`` structure has been made private.
+
 
 Shared Library Versions
 -----------------------
@@ -184,7 +190,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_compressdev.so.1
      librte_cryptodev.so.7
      librte_distributor.so.1
-     librte_eal.so.10
+   + librte_eal.so.11
      librte_efd.so.1
      librte_ethdev.so.12
      librte_eventdev.so.6
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index ebf6ccd3c..1ceb1c07b 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -20,6 +20,7 @@
 #include <rte_eal.h>
 #include <rte_bus.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "eal_filesystem.h"
 
diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index 7ff11d25f..bd7247cc3 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -4,6 +4,8 @@
 
 #include <rte_string_fns.h>
 #include <rte_acl.h>
+#include <rte_tailq.h>
+
 #include "acl.h"
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 9eb78b330..0a3213bbf 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -14,6 +14,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_private.h"
 #include "rte_distributor.h"
diff --git a/lib/librte_distributor/rte_distributor_v20.c b/lib/librte_distributor/rte_distributor_v20.c
index 1fc03b971..cdc0969a8 100644
--- a/lib/librte_distributor/rte_distributor_v20.c
+++ b/lib/librte_distributor/rte_distributor_v20.c
@@ -13,6 +13,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_v20.h"
 #include "rte_distributor_private.h"
diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index ba2bc37b7..337890a61 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -5,6 +5,8 @@
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
 
+#include "eal_memcfg.h"
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index e73a413cc..b33bc4b29 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -24,6 +24,7 @@
 #include "eal_memalloc.h"
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
+#include "eal_memcfg.h"
 #include "malloc_heap.h"
 
 /*
diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
index 521ad7ca1..ef6c909cb 100644
--- a/lib/librte_eal/common/eal_common_memzone.c
+++ b/lib/librte_eal/common/eal_common_memzone.c
@@ -24,6 +24,7 @@
 #include "malloc_heap.h"
 #include "malloc_elem.h"
 #include "eal_private.h"
+#include "eal_memcfg.h"
 
 static inline const struct rte_memzone *
 memzone_lookup_thread_unsafe(const char *name)
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index dc2c13caa..ead06897b 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -23,6 +23,7 @@
 #include <rte_debug.h>
 
 #include "eal_private.h"
+#include "eal_memcfg.h"
 
 TAILQ_HEAD(rte_tailq_elem_head, rte_tailq_elem);
 /* local tailq list */
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
new file mode 100644
index 000000000..466958352
--- /dev/null
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef EAL_MEMCFG_H
+#define EAL_MEMCFG_H
+
+#include <rte_config.h>
+#include <rte_eal_memconfig.h>
+#include <rte_malloc_heap.h>
+#include <rte_memory.h>
+#include <rte_memzone.h>
+#include <rte_pause.h>
+#include <rte_rwlock.h>
+#include <rte_tailq.h>
+
+/**
+ * the structure for the memory configuration for the RTE.
+ * Used by the rte_config structure. It is separated out, as for multi-process
+ * support, the memory details should be shared across instances
+ */
+struct rte_mem_config {
+	volatile uint32_t magic;   /**< Magic number - Sanity check. */
+
+	/* memory topology */
+	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
+	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
+
+	/**
+	 * current lock nest order
+	 *  - qlock->mlock (ring/hash/lpm)
+	 *  - mplock->qlock->mlock (mempool)
+	 * Notice:
+	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
+	 */
+	rte_rwlock_t mlock;   /**< only used by memzone LIB for thread-safe. */
+	rte_rwlock_t qlock;   /**< used for tailq operation for thread safe. */
+	rte_rwlock_t mplock;  /**< only used by mempool LIB for thread-safe. */
+
+	rte_rwlock_t memory_hotplug_lock;
+	/**< indicates whether memory hotplug request is in progress. */
+
+	/* memory segments and zones */
+	struct rte_fbarray memzones; /**< Memzone descriptors. */
+
+	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
+	/**< list of dynamic arrays holding memsegs */
+
+	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ];
+	/**< Tailqs for objects */
+
+	/* Heaps of Malloc */
+	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
+
+	/* next socket ID for external malloc heap */
+	int next_socket_id;
+
+	/* address of mem_config in primary process. used to map shared config
+	 * into exact same address the primary process maps it.
+	 */
+	uint64_t mem_cfg_addr;
+
+	/* legacy mem and single file segments options are shared */
+	uint32_t legacy_mem;
+	uint32_t single_file_segments;
+
+	/* keeps the more restricted dma mask */
+	uint8_t dma_maskbits;
+} __attribute__((packed));
+
+static inline void
+rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
+{
+	/* wait until shared mem_config finish initialising */
+	while (mcfg->magic != RTE_MAGIC)
+		rte_pause();
+}
+
+#endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index 58dcbb96d..1b615c892 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -5,13 +5,12 @@
 #ifndef _RTE_EAL_MEMCONFIG_H_
 #define _RTE_EAL_MEMCONFIG_H_
 
-#include <rte_config.h>
-#include <rte_tailq.h>
-#include <rte_memory.h>
-#include <rte_memzone.h>
-#include <rte_malloc_heap.h>
-#include <rte_rwlock.h>
-#include <rte_pause.h>
+/**
+ * @file
+ *
+ * This API allows access to EAL shared memory configuration through an API.
+ */
+
 #include <rte_fbarray.h>
 
 #ifdef __cplusplus
@@ -38,68 +37,6 @@ struct rte_memseg_list {
 	struct rte_fbarray memseg_arr;
 };
 
-/**
- * the structure for the memory configuration for the RTE.
- * Used by the rte_config structure. It is separated out, as for multi-process
- * support, the memory details should be shared across instances
- */
-struct rte_mem_config {
-	volatile uint32_t magic;   /**< Magic number - Sanity check. */
-
-	/* memory topology */
-	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
-	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
-
-	/**
-	 * current lock nest order
-	 *  - qlock->mlock (ring/hash/lpm)
-	 *  - mplock->qlock->mlock (mempool)
-	 * Notice:
-	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
-	 */
-	rte_rwlock_t mlock;   /**< only used by memzone LIB for thread-safe. */
-	rte_rwlock_t qlock;   /**< used for tailq operation for thread safe. */
-	rte_rwlock_t mplock;  /**< only used by mempool LIB for thread-safe. */
-
-	rte_rwlock_t memory_hotplug_lock;
-	/**< indicates whether memory hotplug request is in progress. */
-
-	/* memory segments and zones */
-	struct rte_fbarray memzones; /**< Memzone descriptors. */
-
-	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
-	/**< list of dynamic arrays holding memsegs */
-
-	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ]; /**< Tailqs for objects */
-
-	/* Heaps of Malloc */
-	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
-
-	/* next socket ID for external malloc heap */
-	int next_socket_id;
-
-	/* address of mem_config in primary process. used to map shared config into
-	 * exact same address the primary process maps it.
-	 */
-	uint64_t mem_cfg_addr;
-
-	/* legacy mem and single file segments options are shared */
-	uint32_t legacy_mem;
-	uint32_t single_file_segments;
-
-	/* keeps the more restricted dma mask */
-	uint8_t dma_maskbits;
-} __attribute__((__packed__));
-
-
-inline static void
-rte_eal_mcfg_wait_complete(struct rte_mem_config* mcfg)
-{
-	/* wait until shared mem_config finish initialising */
-	while(mcfg->magic != RTE_MAGIC)
-		rte_pause();
-}
-
 /**
  * Lock the internal EAL shared memory configuration for shared access.
  */
diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index f1d31de0d..634ca212f 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -20,11 +20,13 @@
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
 #include <rte_memcpy.h>
+#include <rte_memzone.h>
 #include <rte_atomic.h>
 #include <rte_fbarray.h>
 
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "malloc_elem.h"
 #include "malloc_heap.h"
 #include "malloc_mp.h"
diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c
index 7c6112c4e..1f212f834 100644
--- a/lib/librte_eal/common/malloc_mp.c
+++ b/lib/librte_eal/common/malloc_mp.c
@@ -10,6 +10,7 @@
 #include <rte_string_fns.h>
 
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 
 #include "malloc_elem.h"
 #include "malloc_mp.h"
diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index 98e1bdd07..8d2ef8aeb 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -25,6 +25,7 @@
 #include "malloc_elem.h"
 #include "malloc_heap.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 
 
 /* Free the memory space back to heap */
diff --git a/lib/librte_eal/freebsd/eal/Makefile b/lib/librte_eal/freebsd/eal/Makefile
index dc56af582..0974518ab 100644
--- a/lib/librte_eal/freebsd/eal/Makefile
+++ b/lib/librte_eal/freebsd/eal/Makefile
@@ -22,7 +22,7 @@ LDLIBS += -lrte_kvargs
 
 EXPORT_MAP := ../../rte_eal_version.map
 
-LIBABIVER := 10
+LIBABIVER := 11
 
 # specific to freebsd exec-env
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) := eal.c
diff --git a/lib/librte_eal/freebsd/eal/eal_memory.c b/lib/librte_eal/freebsd/eal/eal_memory.c
index 4b092e1f2..9b9a0577a 100644
--- a/lib/librte_eal/freebsd/eal/eal_memory.c
+++ b/lib/librte_eal/freebsd/eal/eal_memory.c
@@ -18,6 +18,7 @@
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
+#include "eal_memcfg.h"
 
 #define EAL_PAGE_SIZE (sysconf(_SC_PAGESIZE))
 
diff --git a/lib/librte_eal/linux/eal/Makefile b/lib/librte_eal/linux/eal/Makefile
index 3b2642eb8..9c885a9c9 100644
--- a/lib/librte_eal/linux/eal/Makefile
+++ b/lib/librte_eal/linux/eal/Makefile
@@ -10,7 +10,7 @@ ARCH_DIR ?= $(RTE_ARCH)
 EXPORT_MAP := ../../rte_eal_version.map
 VPATH += $(RTE_SDK)/lib/librte_eal/common/arch/$(ARCH_DIR)
 
-LIBABIVER := 10
+LIBABIVER := 11
 
 VPATH += $(RTE_SDK)/lib/librte_eal/common
 
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 3e1d6eb6a..0fc99de5b 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -57,6 +57,7 @@
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
+#include "eal_memcfg.h"
 #include "eal_options.h"
 #include "eal_vfio.h"
 
diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c
index 2019636fb..1f6a7c18f 100644
--- a/lib/librte_eal/linux/eal/eal_memalloc.c
+++ b/lib/librte_eal/linux/eal/eal_memalloc.c
@@ -44,6 +44,7 @@
 #include "eal_filesystem.h"
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_private.h"
 
 const int anonymous_hugepages_supported =
diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c
index 1853acea5..9c948a374 100644
--- a/lib/librte_eal/linux/eal/eal_memory.c
+++ b/lib/librte_eal/linux/eal/eal_memory.c
@@ -46,6 +46,7 @@
 
 #include "eal_private.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index 924cba526..5d679ca68 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -15,6 +15,7 @@
 #include <rte_vfio.h>
 
 #include "eal_filesystem.h"
+#include "eal_memcfg.h"
 #include "eal_vfio.h"
 #include "eal_private.h"
 
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index fa36b20e0..5c5023dd4 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -12,7 +12,7 @@ subdir('common') # defines common_sources, common_objs, etc.
 dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env + '/eal')
 
-version = 10  # the version of the EAL API
+version = 11  # the version of the EAL API
 allow_experimental_apis = true
 deps += 'kvargs'
 if dpdk_conf.has('RTE_USE_LIBBSD')
diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index b808ce99f..d3d019578 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -20,6 +20,7 @@
 #include <rte_ring.h>
 #include <rte_jhash.h>
 #include <rte_hash_crc.h>
+#include <rte_tailq.h>
 
 #include "rte_efd.h"
 #if defined(RTE_ARCH_X86)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 865c744d9..b76518b4c 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -27,6 +27,7 @@
 #include <rte_ring.h>
 #include <rte_compat.h>
 #include <rte_vect.h>
+#include <rte_tailq.h>
 
 #include "rte_hash.h"
 #include "rte_cuckoo_hash.h"
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index db118c930..576e8e666 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -20,6 +20,7 @@
 #include <rte_cpuflags.h>
 #include <rte_log.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_fbk_hash.h"
 
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index b91f74216..70c24ac1f 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -21,6 +21,7 @@
 #include <rte_errno.h>
 #include <rte_rwlock.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_lpm.h"
 
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index 5af74a539..9b8aeb972 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -24,6 +24,7 @@
 #include <rte_hash.h>
 #include <assert.h>
 #include <rte_jhash.h>
+#include <rte_tailq.h>
 
 #include "rte_lpm6.h"
 
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index efed28dd9..e0e7f127e 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -10,6 +10,7 @@
 #include <rte_memory.h>
 #include <rte_malloc.h>
 #include <rte_errno.h>
+#include <rte_tailq.h>
 
 #include "rte_member.h"
 #include "rte_member_ht.h"
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 5c688d456..7260ce0be 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -30,6 +30,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_mempool.h"
 
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index ae6e3f578..3c9f0e2d0 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -11,6 +11,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
 #include <rte_malloc.h>
+#include <rte_tailq.h>
 
 #include "rte_reorder.h"
 
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index 9ea26a631..b30b2aa7b 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -30,6 +30,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_ring.h"
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 10/14] eal: remove packed attribute from mcfg structure
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (35 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 09/14] eal: hide shared memory config Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 11/14] eal: uninline wait for mcfg complete function Anatoly Burakov
                   ` (3 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

There is no reason to pack the memconfig structure, and doing so
gives out warnings in some static analyzers. Fix it by removing
the packed attributed.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_memcfg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 466958352..22459a55a 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -66,7 +66,7 @@ struct rte_mem_config {
 
 	/* keeps the more restricted dma mask */
 	uint8_t dma_maskbits;
-} __attribute__((packed));
+};
 
 static inline void
 rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 11/14] eal: uninline wait for mcfg complete function
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (36 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 10/14] eal: remove packed attribute from mcfg structure Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 12/14] eal: unify and move " Anatoly Burakov
                   ` (2 subsequent siblings)
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, david.marchand, thomas, stephen

Currently, the function to wait until config completion is
static inline for no reason. Move its implementation to
an EAL common file.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 10 ++++++++++
 lib/librte_eal/common/eal_memcfg.h      | 10 +++-------
 lib/librte_eal/freebsd/eal/eal.c        |  3 ++-
 lib/librte_eal/linux/eal/eal.c          |  2 +-
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 337890a61..30969c6bf 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -7,6 +7,16 @@
 
 #include "eal_memcfg.h"
 
+void
+eal_mcfg_wait_complete(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	/* wait until shared mem_config finish initialising */
+	while (mcfg->magic != RTE_MAGIC)
+		rte_pause();
+}
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 22459a55a..7319d9f7a 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -68,12 +68,8 @@ struct rte_mem_config {
 	uint8_t dma_maskbits;
 };
 
-static inline void
-rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
-{
-	/* wait until shared mem_config finish initialising */
-	while (mcfg->magic != RTE_MAGIC)
-		rte_pause();
-}
+/* wait until primary process initialization is complete */
+void
+eal_mcfg_wait_complete(void);
 
 #endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index ce7a5f91d..b3c96b5cd 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -52,6 +52,7 @@
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
 #include "eal_options.h"
+#include "eal_memcfg.h"
 
 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
 
@@ -352,7 +353,7 @@ rte_config_init(void)
 		break;
 	case RTE_PROC_SECONDARY:
 		rte_eal_config_attach();
-		rte_eal_mcfg_wait_complete(rte_config.mem_config);
+		eal_mcfg_wait_complete();
 		rte_eal_config_reattach();
 		break;
 	case RTE_PROC_AUTO:
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 0fc99de5b..9168a3e47 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -474,7 +474,7 @@ rte_config_init(void)
 		break;
 	case RTE_PROC_SECONDARY:
 		rte_eal_config_attach();
-		rte_eal_mcfg_wait_complete(rte_config.mem_config);
+		eal_mcfg_wait_complete();
 		rte_eal_config_reattach();
 		eal_update_internal_config();
 		break;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 12/14] eal: unify and move mcfg complete function
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (37 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 11/14] eal: uninline wait for mcfg complete function Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 13/14] eal: unify internal config initialization Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 14/14] eal: prevent different primary/secondary process versions Anatoly Burakov
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, david.marchand, thomas, stephen

Currently, mcfg completion function exists in two independent
implementations doing the same thing, which is bug prone.
Unify the two functions and move them into one place.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 14 ++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  5 +++++
 lib/librte_eal/freebsd/eal/eal.c        | 12 +-----------
 lib/librte_eal/linux/eal/eal.c          | 12 +-----------
 4 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 30969c6bf..dc6665d6a 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -5,8 +5,22 @@
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
 
+#include "eal_internal_cfg.h"
 #include "eal_memcfg.h"
 
+void
+eal_mcfg_complete(void)
+{
+	struct rte_config *cfg = rte_eal_get_configuration();
+	struct rte_mem_config *mcfg = cfg->mem_config;
+
+	/* ALL shared mem_config related INIT DONE */
+	if (cfg->process_type == RTE_PROC_PRIMARY)
+		mcfg->magic = RTE_MAGIC;
+
+	internal_config.init_complete = 1;
+}
+
 void
 eal_mcfg_wait_complete(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 7319d9f7a..6e2d3abc9 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -72,4 +72,9 @@ struct rte_mem_config {
 void
 eal_mcfg_wait_complete(void);
 
+/* set mem config as complete */
+void
+eal_mcfg_complete(void);
+
 #endif /* EAL_MEMCFG_H */
+
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index b3c96b5cd..e43e01042 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -597,16 +597,6 @@ sync_func(__attribute__((unused)) void *arg)
 	return 0;
 }
 
-inline static void
-rte_eal_mcfg_complete(void)
-{
-	/* ALL shared mem_config related INIT DONE */
-	if (rte_config.process_type == RTE_PROC_PRIMARY)
-		rte_config.mem_config->magic = RTE_MAGIC;
-
-	internal_config.init_complete = 1;
-}
-
 /* return non-zero if hugepages are enabled. */
 int rte_eal_has_hugepages(void)
 {
@@ -883,7 +873,7 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	rte_eal_mcfg_complete();
+	eal_mcfg_complete();
 
 	/* Call each registered callback, if enabled */
 	rte_option_init();
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 9168a3e47..4b5deaa70 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -897,16 +897,6 @@ sync_func(__attribute__((unused)) void *arg)
 	return 0;
 }
 
-inline static void
-rte_eal_mcfg_complete(void)
-{
-	/* ALL shared mem_config related INIT DONE */
-	if (rte_config.process_type == RTE_PROC_PRIMARY)
-		rte_config.mem_config->magic = RTE_MAGIC;
-
-	internal_config.init_complete = 1;
-}
-
 /*
  * Request iopl privilege for all RPL, returns 0 on success
  * iopl() call is mostly for the i386 architecture. For other architectures,
@@ -1229,7 +1219,7 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	rte_eal_mcfg_complete();
+	eal_mcfg_complete();
 
 	/* Call each registered callback, if enabled */
 	rte_option_init();
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 13/14] eal: unify internal config initialization
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (38 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 12/14] eal: unify and move " Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 14/14] eal: prevent different primary/secondary process versions Anatoly Burakov
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, david.marchand, thomas, stephen

Currently, each EAL will update internal/shared config in their
own way at init, resulting in needless duplication of code and
OS-dependent behavior. Move the functions to a common file and
add missing FreeBSD steps.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 18 ++++++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  8 ++++++++
 lib/librte_eal/freebsd/eal/eal.c        |  2 ++
 lib/librte_eal/linux/eal/eal.c          | 22 ++--------------------
 4 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index dc6665d6a..fe8d2b726 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -31,6 +31,24 @@ eal_mcfg_wait_complete(void)
 		rte_pause();
 }
 
+void
+eal_mcfg_update_internal(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	internal_config.legacy_mem = mcfg->legacy_mem;
+	internal_config.single_file_segments = mcfg->single_file_segments;
+}
+
+void
+eal_mcfg_update_from_internal(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	mcfg->legacy_mem = internal_config.legacy_mem;
+	mcfg->single_file_segments = internal_config.single_file_segments;
+}
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 6e2d3abc9..908542e18 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -68,6 +68,14 @@ struct rte_mem_config {
 	uint8_t dma_maskbits;
 };
 
+/* update internal config from shared mem config */
+void
+eal_mcfg_update_internal(void);
+
+/* update shared mem config from internal config */
+void
+eal_mcfg_update_from_internal(void);
+
 /* wait until primary process initialization is complete */
 void
 eal_mcfg_wait_complete(void);
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index e43e01042..81eb44670 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -350,11 +350,13 @@ rte_config_init(void)
 	switch (rte_config.process_type){
 	case RTE_PROC_PRIMARY:
 		rte_eal_config_create();
+		eal_mcfg_update_internal();
 		break;
 	case RTE_PROC_SECONDARY:
 		rte_eal_config_attach();
 		eal_mcfg_wait_complete();
 		rte_eal_config_reattach();
+		eal_mcfg_update_from_internal();
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 4b5deaa70..e2be87e23 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -443,24 +443,6 @@ eal_proc_type_detect(void)
 	return ptype;
 }
 
-/* copies data from internal config to shared config */
-static void
-eal_update_mem_config(void)
-{
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	mcfg->legacy_mem = internal_config.legacy_mem;
-	mcfg->single_file_segments = internal_config.single_file_segments;
-}
-
-/* copies data from shared config to internal config */
-static void
-eal_update_internal_config(void)
-{
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	internal_config.legacy_mem = mcfg->legacy_mem;
-	internal_config.single_file_segments = mcfg->single_file_segments;
-}
-
 /* Sets up rte_config structure with the pointer to shared memory config.*/
 static void
 rte_config_init(void)
@@ -470,13 +452,13 @@ rte_config_init(void)
 	switch (rte_config.process_type){
 	case RTE_PROC_PRIMARY:
 		rte_eal_config_create();
-		eal_update_mem_config();
+		eal_mcfg_update_from_internal();
 		break;
 	case RTE_PROC_SECONDARY:
 		rte_eal_config_attach();
 		eal_mcfg_wait_complete();
 		rte_eal_config_reattach();
-		eal_update_internal_config();
+		eal_mcfg_update_internal();
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v2 14/14] eal: prevent different primary/secondary process versions
  2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
                   ` (39 preceding siblings ...)
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 13/14] eal: unify internal config initialization Anatoly Burakov
@ 2019-06-25 16:05 ` Anatoly Burakov
  40 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-25 16:05 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, david.marchand, thomas, stephen

Currently, nothing stops DPDK to attempt to run primary and
secondary processes while having different versions. This
can lead to all sorts of weird behavior and makes it harder
to maintain compatibility without breaking ABI every once
in a while.

Fix it by explicitly disallowing running different DPDK
versions as primary and secondary processes.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 15 +++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  6 ++++++
 lib/librte_eal/freebsd/eal/eal.c        | 14 ++++++++++++--
 lib/librte_eal/linux/eal/eal.c          | 14 ++++++++++++--
 4 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index fe8d2b726..1825d9083 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -4,6 +4,7 @@
 
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
+#include <rte_version.h>
 
 #include "eal_internal_cfg.h"
 #include "eal_memcfg.h"
@@ -31,6 +32,18 @@ eal_mcfg_wait_complete(void)
 		rte_pause();
 }
 
+int
+eal_mcfg_check_version(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	/* check if version from memconfig matches compiled in macro */
+	if (mcfg->version != RTE_VERSION)
+		return -1;
+
+	return 0;
+}
+
 void
 eal_mcfg_update_internal(void)
 {
@@ -47,6 +60,8 @@ eal_mcfg_update_from_internal(void)
 
 	mcfg->legacy_mem = internal_config.legacy_mem;
 	mcfg->single_file_segments = internal_config.single_file_segments;
+	/* record current DPDK version */
+	mcfg->version = RTE_VERSION;
 }
 
 void
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 908542e18..e1aae32df 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -21,6 +21,8 @@
  */
 struct rte_mem_config {
 	volatile uint32_t magic;   /**< Magic number - Sanity check. */
+	uint32_t version;
+	/**< Prevent secondary processes using different DPDK versions. */
 
 	/* memory topology */
 	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
@@ -80,6 +82,10 @@ eal_mcfg_update_from_internal(void);
 void
 eal_mcfg_wait_complete(void);
 
+/* check if DPDK version of current process matches one stored in the config */
+int
+eal_mcfg_check_version(void);
+
 /* set mem config as complete */
 void
 eal_mcfg_complete(void);
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 81eb44670..ab06d9c6f 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -342,7 +342,7 @@ eal_proc_type_detect(void)
 }
 
 /* Sets up rte_config structure with the pointer to shared memory config.*/
-static void
+static int
 rte_config_init(void)
 {
 	rte_config.process_type = internal_config.process_type;
@@ -355,6 +355,10 @@ rte_config_init(void)
 	case RTE_PROC_SECONDARY:
 		rte_eal_config_attach();
 		eal_mcfg_wait_complete();
+		if (eal_mcfg_check_version() < 0) {
+			RTE_LOG(ERR, EAL, "Primary and secondary process DPDK version mismatch\n");
+			return -1;
+		}
 		rte_eal_config_reattach();
 		eal_mcfg_update_from_internal();
 		break;
@@ -362,6 +366,7 @@ rte_config_init(void)
 	case RTE_PROC_INVALID:
 		rte_panic("Invalid process type\n");
 	}
+	return 0;
 }
 
 /* display usage */
@@ -686,7 +691,12 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	rte_config_init();
+	if (rte_config_init() < 0) {
+		rte_eal_init_alert("Cannot init config");
+		rte_errno = EINVAL;
+		rte_atomic32_clear(&run_once);
+		return -1;
+	}
 
 	if (rte_eal_intr_init() < 0) {
 		rte_eal_init_alert("Cannot init interrupt-handling thread");
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index e2be87e23..4a38718aa 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -444,7 +444,7 @@ eal_proc_type_detect(void)
 }
 
 /* Sets up rte_config structure with the pointer to shared memory config.*/
-static void
+static int
 rte_config_init(void)
 {
 	rte_config.process_type = internal_config.process_type;
@@ -457,6 +457,10 @@ rte_config_init(void)
 	case RTE_PROC_SECONDARY:
 		rte_eal_config_attach();
 		eal_mcfg_wait_complete();
+		if (eal_mcfg_check_version() < 0) {
+			RTE_LOG(ERR, EAL, "Primary and secondary process DPDK version mismatch\n");
+			return -1;
+		}
 		rte_eal_config_reattach();
 		eal_mcfg_update_internal();
 		break;
@@ -464,6 +468,7 @@ rte_config_init(void)
 	case RTE_PROC_INVALID:
 		rte_panic("Invalid process type\n");
 	}
+	return 0;
 }
 
 /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */
@@ -971,7 +976,12 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	rte_config_init();
+	if (rte_config_init() < 0) {
+		rte_eal_init_alert("Cannot init config");
+		rte_errno = EINVAL;
+		rte_atomic32_clear(&run_once);
+		return -1;
+	}
 
 	if (rte_eal_intr_init() < 0) {
 		rte_eal_init_alert("Cannot init interrupt-handling thread");
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v2 02/14] drivers: use new memory locking API
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 02/14] drivers: use new memory locking API Anatoly Burakov
@ 2019-06-27  9:24   ` Hemant Agrawal
  2019-06-28 15:21   ` Yongseok Koh
  1 sibling, 0 replies; 117+ messages in thread
From: Hemant Agrawal @ 2019-06-27  9:24 UTC (permalink / raw)
  To: Anatoly Burakov, dev
  Cc: Shreyansh Jain, Matan Azrad, Shahaf Shuler, Yongseok Koh,
	Maxime Coquelin, Tiwei Bie, Zhihong Wang, david.marchand, thomas,
	stephen

For fslmc changes:

Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>


^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 00/14] Make shared memory config non-public
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
@ 2019-06-27 11:38   ` Anatoly Burakov
  2019-06-27 15:36     ` Stephen Hemminger
                       ` (10 more replies)
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 01/14] eal: add API to lock/unlock memory hotplug Anatoly Burakov
                     ` (13 subsequent siblings)
  14 siblings, 11 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:38 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

This patchset removes the shared memory config from public
API, and replaces all usages of said config with new API
calls.

A lot of the patchset is a search-and-replace job and should
be pretty easy to review. The rest are pretty trivial EAL
changes.

This patchset depends on FreeBSD fixes patchset:

http://patches.dpdk.org/project/dpdk/list/?series=5196

v3:
- Rebase on top of latest master

v2:
- Collapsed all changes into fewer patches
- Addressed review comments
- Created a new file to store the code
- Changed namespace to "rte_mcfg_"
- Added some unification around config init
- Removed "packed" attribute from mem config
- Removed unnecessary inlining
- Added a check to explicitly forbid running multiprocess
  applications that differ in their DPDK versions

Anatoly Burakov (14):
  eal: add API to lock/unlock memory hotplug
  drivers: use new memory locking API
  lib: use new memory locking API
  eal: add EAL tailq list lock/unlock API
  lib: use new tailq locking API
  eal: add new API to lock/unlock mempool list
  mempool: use new mempool list locking API
  eal: remove unused macros
  eal: hide shared memory config
  eal: remove packed attribute from mcfg structure
  eal: uninline wait for mcfg complete function
  eal: unify and move mcfg complete function
  eal: unify internal config initialization
  eal: prevent different primary/secondary process versions

 app/test/test_memzone.c                       |   1 +
 app/test/test_tailq.c                         |   1 +
 doc/guides/rel_notes/deprecation.rst          |   3 -
 doc/guides/rel_notes/release_19_08.rst        |   8 +-
 drivers/bus/fslmc/fslmc_vfio.c                |   8 +-
 drivers/bus/pci/linux/pci_vfio.c              |   1 +
 drivers/net/mlx4/mlx4_mr.c                    |  11 +-
 drivers/net/mlx5/mlx5_mr.c                    |  11 +-
 .../net/virtio/virtio_user/virtio_user_dev.c  |   7 +-
 lib/librte_acl/rte_acl.c                      |  20 +--
 lib/librte_distributor/rte_distributor.c      |   5 +-
 lib/librte_distributor/rte_distributor_v20.c  |   5 +-
 lib/librte_eal/common/eal_common_mcfg.c       | 149 ++++++++++++++++++
 lib/librte_eal/common/eal_common_memory.c     |  44 +++---
 lib/librte_eal/common/eal_common_memzone.c    |   1 +
 lib/librte_eal/common/eal_common_tailqs.c     |   5 +-
 lib/librte_eal/common/eal_memcfg.h            |  93 +++++++++++
 lib/librte_eal/common/include/rte_eal.h       |  10 --
 .../common/include/rte_eal_memconfig.h        | 143 +++++++++--------
 lib/librte_eal/common/malloc_heap.c           |  16 +-
 lib/librte_eal/common/malloc_mp.c             |   1 +
 lib/librte_eal/common/meson.build             |   1 +
 lib/librte_eal/common/rte_malloc.c            |  33 ++--
 lib/librte_eal/freebsd/eal/Makefile           |   3 +-
 lib/librte_eal/freebsd/eal/eal.c              |  22 ++-
 lib/librte_eal/freebsd/eal/eal_memory.c       |   1 +
 lib/librte_eal/linux/eal/Makefile             |   3 +-
 lib/librte_eal/linux/eal/eal.c                |  42 ++---
 lib/librte_eal/linux/eal/eal_memalloc.c       |   1 +
 lib/librte_eal/linux/eal/eal_memory.c         |   1 +
 lib/librte_eal/linux/eal/eal_vfio.c           |  17 +-
 lib/librte_eal/meson.build                    |   2 +-
 lib/librte_eal/rte_eal_version.map            |  12 ++
 lib/librte_efd/rte_efd.c                      |  15 +-
 lib/librte_eventdev/rte_event_ring.c          |  16 +-
 lib/librte_hash/rte_cuckoo_hash.c             |  17 +-
 lib/librte_hash/rte_fbk_hash.c                |  15 +-
 lib/librte_kni/rte_kni.c                      |  16 +-
 lib/librte_lpm/rte_lpm.c                      |  25 +--
 lib/librte_lpm/rte_lpm6.c                     |  15 +-
 lib/librte_member/rte_member.c                |  17 +-
 lib/librte_mempool/rte_mempool.c              |  27 ++--
 lib/librte_reorder/rte_reorder.c              |  15 +-
 lib/librte_ring/rte_ring.c                    |  19 +--
 lib/librte_stack/rte_stack.c                  |  18 +--
 45 files changed, 566 insertions(+), 330 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_mcfg.c
 create mode 100644 lib/librte_eal/common/eal_memcfg.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 01/14] eal: add API to lock/unlock memory hotplug
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
@ 2019-06-27 11:38   ` Anatoly Burakov
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 02/14] drivers: use new memory locking API Anatoly Burakov
                     ` (12 subsequent siblings)
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:38 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, david.marchand, thomas, stephen

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 <anatoly.burakov@intel.com>
---
 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 <rte_config.h>
+#include <rte_eal_memconfig.h>
+
+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

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 02/14] drivers: use new memory locking API
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 01/14] eal: add API to lock/unlock memory hotplug Anatoly Burakov
@ 2019-06-27 11:38   ` Anatoly Burakov
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 03/14] lib: " Anatoly Burakov
                     ` (11 subsequent siblings)
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:38 UTC (permalink / raw)
  To: dev
  Cc: Hemant Agrawal, Shreyansh Jain, Matan Azrad, Shahaf Shuler,
	Yongseok Koh, Maxime Coquelin, Tiwei Bie, Zhihong Wang,
	david.marchand, thomas, stephen

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c                   |  8 +++-----
 drivers/net/mlx4/mlx4_mr.c                       | 11 +++++------
 drivers/net/mlx5/mlx5_mr.c                       | 11 +++++------
 drivers/net/virtio/virtio_user/virtio_user_dev.c |  7 +++----
 4 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 1aae56fa9..44e4fa6e2 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -347,14 +347,12 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,
 int rte_fslmc_vfio_dmamap(void)
 {
 	int i = 0, ret;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 
 	/* Lock before parsing and registering callback to memory subsystem */
-	rte_rwlock_read_lock(mem_lock);
+	rte_mcfg_mem_read_lock();
 
 	if (rte_memseg_walk(fslmc_dmamap_seg, &i) < 0) {
-		rte_rwlock_read_unlock(mem_lock);
+		rte_mcfg_mem_read_unlock();
 		return -1;
 	}
 
@@ -378,7 +376,7 @@ int rte_fslmc_vfio_dmamap(void)
 	/* Existing segments have been mapped and memory callback for hotplug
 	 * has been installed.
 	 */
-	rte_rwlock_read_unlock(mem_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return 0;
 }
diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
index 48d458ad4..80827ce75 100644
--- a/drivers/net/mlx4/mlx4_mr.c
+++ b/drivers/net/mlx4/mlx4_mr.c
@@ -593,7 +593,6 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		       uintptr_t addr)
 {
 	struct mlx4_priv *priv = dev->data->dev_private;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	const struct rte_memseg_list *msl;
 	const struct rte_memseg *ms;
 	struct mlx4_mr *mr = NULL;
@@ -696,7 +695,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	 * just single page. If not, go on with the big chunk atomically from
 	 * here.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	data_re = data;
 	if (len > msl->page_sz &&
 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
@@ -714,7 +713,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		 */
 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
 		data.end = data.start + msl->page_sz;
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		mr_free(mr);
 		goto alloc_resources;
 	}
@@ -734,7 +733,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		DEBUG("port %u found MR for %p on final lookup, abort",
 		      dev->data->port_id, (void *)addr);
 		rte_rwlock_write_unlock(&priv->mr.rwlock);
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		/*
 		 * Must be unlocked before calling rte_free() because
 		 * mlx4_mr_mem_event_free_cb() can be called inside.
@@ -802,12 +801,12 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	/* Lookup can't fail. */
 	assert(entry->lkey != UINT32_MAX);
 	rte_rwlock_write_unlock(&priv->mr.rwlock);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return entry->lkey;
 err_mrlock:
 	rte_rwlock_write_unlock(&priv->mr.rwlock);
 err_memlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 err_nolock:
 	/*
 	 * In case of error, as this can be called in a datapath, a warning
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 66e8e874e..872d0591e 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -580,7 +580,6 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_ibv_shared *sh = priv->sh;
 	struct mlx5_dev_config *config = &priv->config;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	const struct rte_memseg_list *msl;
 	const struct rte_memseg *ms;
 	struct mlx5_mr *mr = NULL;
@@ -684,7 +683,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	 * just single page. If not, go on with the big chunk atomically from
 	 * here.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	data_re = data;
 	if (len > msl->page_sz &&
 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
@@ -702,7 +701,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 		 */
 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
 		data.end = data.start + msl->page_sz;
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		mr_free(mr);
 		goto alloc_resources;
 	}
@@ -722,7 +721,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 		DEBUG("port %u found MR for %p on final lookup, abort",
 		      dev->data->port_id, (void *)addr);
 		rte_rwlock_write_unlock(&sh->mr.rwlock);
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		/*
 		 * Must be unlocked before calling rte_free() because
 		 * mlx5_mr_mem_event_free_cb() can be called inside.
@@ -790,12 +789,12 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	/* Lookup can't fail. */
 	assert(entry->lkey != UINT32_MAX);
 	rte_rwlock_write_unlock(&sh->mr.rwlock);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return entry->lkey;
 err_mrlock:
 	rte_rwlock_write_unlock(&sh->mr.rwlock);
 err_memlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 err_nolock:
 	/*
 	 * In case of error, as this can be called in a datapath, a warning
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index e743695e4..c3ab9a21d 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -125,7 +125,6 @@ is_vhost_user_by_type(const char *path)
 int
 virtio_user_start_device(struct virtio_user_dev *dev)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	uint64_t features;
 	int ret;
 
@@ -142,7 +141,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 	 * replaced when we get proper supports from the
 	 * memory subsystem in the future.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	pthread_mutex_lock(&dev->mutex);
 
 	if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0)
@@ -180,12 +179,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 
 	dev->started = true;
 	pthread_mutex_unlock(&dev->mutex);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return 0;
 error:
 	pthread_mutex_unlock(&dev->mutex);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	/* TODO: free resource here or caller to check */
 	return -1;
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 03/14] lib: use new memory locking API
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (2 preceding siblings ...)
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 02/14] drivers: use new memory locking API Anatoly Burakov
@ 2019-06-27 11:38   ` Anatoly Burakov
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 04/14] eal: add EAL tailq list lock/unlock API Anatoly Burakov
                     ` (10 subsequent siblings)
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:38 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_memory.c | 43 ++++++++++-------------
 lib/librte_eal/common/malloc_heap.c       | 14 ++++----
 lib/librte_eal/common/rte_malloc.c        | 32 ++++++++---------
 lib/librte_eal/linux/eal/eal_vfio.c       | 16 ++++-----
 4 files changed, 44 insertions(+), 61 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 5ae8d0124..e73a413cc 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -596,13 +596,12 @@ rte_memseg_contig_walk_thread_unsafe(rte_memseg_contig_walk_t func, void *arg)
 int __rte_experimental
 rte_memseg_contig_walk(rte_memseg_contig_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_contig_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -638,13 +637,12 @@ rte_memseg_walk_thread_unsafe(rte_memseg_walk_t func, void *arg)
 int __rte_experimental
 rte_memseg_walk(rte_memseg_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -671,13 +669,12 @@ rte_memseg_list_walk_thread_unsafe(rte_memseg_list_walk_t func, void *arg)
 int __rte_experimental
 rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_list_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -727,12 +724,11 @@ rte_memseg_get_fd_thread_unsafe(const struct rte_memseg *ms)
 int __rte_experimental
 rte_memseg_get_fd(const struct rte_memseg *ms)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_get_fd_thread_unsafe(ms);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -783,12 +779,11 @@ rte_memseg_get_fd_offset_thread_unsafe(const struct rte_memseg *ms,
 int __rte_experimental
 rte_memseg_get_fd_offset(const struct rte_memseg *ms, size_t *offset)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_get_fd_offset_thread_unsafe(ms, offset);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -809,7 +804,7 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* make sure the segment doesn't already exist */
 	if (malloc_heap_find_external_seg(va_addr, len) != NULL) {
@@ -838,14 +833,13 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
 	/* memseg list successfully created - increment next socket ID */
 	mcfg->next_socket_id++;
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
 int __rte_experimental
 rte_extmem_unregister(void *va_addr, size_t len)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct rte_memseg_list *msl;
 	int ret = 0;
 
@@ -853,7 +847,7 @@ rte_extmem_unregister(void *va_addr, size_t len)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our segment */
 	msl = malloc_heap_find_external_seg(va_addr, len);
@@ -865,14 +859,13 @@ rte_extmem_unregister(void *va_addr, size_t len)
 
 	ret = malloc_heap_destroy_external_seg(msl);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
 static int
 sync_memory(void *va_addr, size_t len, bool attach)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct rte_memseg_list *msl;
 	int ret = 0;
 
@@ -880,7 +873,7 @@ sync_memory(void *va_addr, size_t len, bool attach)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our segment */
 	msl = malloc_heap_find_external_seg(va_addr, len);
@@ -895,7 +888,7 @@ sync_memory(void *va_addr, size_t len, bool attach)
 		ret = rte_fbarray_detach(&msl->memseg_arr);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
@@ -923,7 +916,7 @@ rte_eal_memory_init(void)
 		return -1;
 
 	/* lock mem hotplug here, to prevent races while we init */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 
 	if (rte_eal_memseg_init() < 0)
 		goto fail;
@@ -942,6 +935,6 @@ rte_eal_memory_init(void)
 
 	return 0;
 fail:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return -1;
 }
diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index f9235932e..f1d31de0d 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -485,10 +485,9 @@ try_expand_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,
 		int socket, unsigned int flags, size_t align, size_t bound,
 		bool contig)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		ret = try_expand_heap_primary(heap, pg_sz, elt_size, socket,
@@ -498,7 +497,7 @@ try_expand_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,
 				flags, align, bound, contig);
 	}
 
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
@@ -821,7 +820,6 @@ malloc_heap_free_pages(void *aligned_start, size_t aligned_len)
 int
 malloc_heap_free(struct malloc_elem *elem)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap;
 	void *start, *aligned_start, *end, *aligned_end;
 	size_t len, aligned_len, page_sz;
@@ -935,7 +933,7 @@ malloc_heap_free(struct malloc_elem *elem)
 
 	/* now we can finally free us some pages */
 
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/*
 	 * we allow secondary processes to clear the heap of this allocated
@@ -990,7 +988,7 @@ malloc_heap_free(struct malloc_elem *elem)
 	RTE_LOG(DEBUG, EAL, "Heap on socket %d was shrunk by %zdMB\n",
 		msl->socket_id, aligned_len >> 20ULL);
 
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 free_unlock:
 	rte_spinlock_unlock(&(heap->lock));
 	return ret;
@@ -1344,7 +1342,7 @@ rte_eal_malloc_heap_init(void)
 
 	if (register_mp_requests()) {
 		RTE_LOG(ERR, EAL, "Couldn't register malloc multiprocess actions\n");
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		return -1;
 	}
 
@@ -1352,7 +1350,7 @@ rte_eal_malloc_heap_init(void)
 	 * even come before primary itself is fully initialized, and secondaries
 	 * do not need to initialize the heap.
 	 */
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	/* secondary process does not need to initialize anything */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index 54792ea5b..98e1bdd07 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -223,7 +223,7 @@ rte_malloc_heap_get_socket(const char *name)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	for (idx = 0; idx < RTE_MAX_HEAPS; idx++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[idx];
 
@@ -239,7 +239,7 @@ rte_malloc_heap_get_socket(const char *name)
 		rte_errno = ENOENT;
 		ret = -1;
 	}
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -254,7 +254,7 @@ rte_malloc_heap_socket_is_external(int socket_id)
 	if (socket_id == SOCKET_ID_ANY)
 		return 0;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	for (idx = 0; idx < RTE_MAX_HEAPS; idx++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[idx];
 
@@ -264,7 +264,7 @@ rte_malloc_heap_socket_is_external(int socket_id)
 			break;
 		}
 	}
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -352,7 +352,6 @@ int
 rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 		rte_iova_t iova_addrs[], unsigned int n_pages, size_t page_sz)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	unsigned int n;
@@ -369,7 +368,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our heap */
 	heap = find_named_heap(heap_name);
@@ -398,7 +397,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 	rte_spinlock_unlock(&heap->lock);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -406,7 +405,6 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 int
 rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	int ret;
@@ -418,7 +416,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 	/* find our heap */
 	heap = find_named_heap(heap_name);
 	if (heap == NULL) {
@@ -448,7 +446,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 	ret = malloc_heap_destroy_external_seg(msl);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -456,7 +454,6 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 static int
 sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	int ret;
@@ -468,7 +465,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 
 	/* find our heap */
 	heap = find_named_heap(heap_name);
@@ -516,7 +513,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 		}
 	}
 unlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return ret;
 }
 
@@ -549,7 +546,7 @@ rte_malloc_heap_create(const char *heap_name)
 	/* check if there is space in the heap list, or if heap with this name
 	 * already exists.
 	 */
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	for (i = 0; i < RTE_MAX_HEAPS; i++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[i];
@@ -578,7 +575,7 @@ rte_malloc_heap_create(const char *heap_name)
 	/* we're sure that we can create a new heap, so do it */
 	ret = malloc_heap_create(heap, heap_name);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -586,7 +583,6 @@ rte_malloc_heap_create(const char *heap_name)
 int
 rte_malloc_heap_destroy(const char *heap_name)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	int ret;
 
@@ -597,7 +593,7 @@ rte_malloc_heap_destroy(const char *heap_name)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* start from non-socket heaps */
 	heap = find_named_heap(heap_name);
@@ -621,7 +617,7 @@ rte_malloc_heap_destroy(const char *heap_name)
 	if (ret < 0)
 		rte_spinlock_unlock(&heap->lock);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index 6892a2c14..924cba526 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -635,8 +635,6 @@ int
 rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 		int *vfio_dev_fd, struct vfio_device_info *device_info)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 	struct vfio_group_status group_status = {
 			.argsz = sizeof(group_status)
 	};
@@ -739,7 +737,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 			/* lock memory hotplug before mapping and release it
 			 * after registering callback, to prevent races
 			 */
-			rte_rwlock_read_lock(mem_lock);
+			rte_mcfg_mem_read_lock();
 			if (vfio_cfg == default_vfio_cfg)
 				ret = t->dma_map_func(vfio_container_fd);
 			else
@@ -750,7 +748,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 					dev_addr, errno, strerror(errno));
 				close(vfio_group_fd);
 				rte_vfio_clear_group(vfio_group_fd);
-				rte_rwlock_read_unlock(mem_lock);
+				rte_mcfg_mem_read_unlock();
 				return -1;
 			}
 
@@ -781,7 +779,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 							map->len);
 					rte_spinlock_recursive_unlock(
 							&user_mem_maps->lock);
-					rte_rwlock_read_unlock(mem_lock);
+					rte_mcfg_mem_read_unlock();
 					return -1;
 				}
 			}
@@ -795,7 +793,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 			else
 				ret = 0;
 			/* unlock memory hotplug */
-			rte_rwlock_read_unlock(mem_lock);
+			rte_mcfg_mem_read_unlock();
 
 			if (ret && rte_errno != ENOTSUP) {
 				RTE_LOG(ERR, EAL, "Could not install memory event callback for VFIO\n");
@@ -862,8 +860,6 @@ int
 rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 		    int vfio_dev_fd)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 	struct vfio_group_status group_status = {
 			.argsz = sizeof(group_status)
 	};
@@ -876,7 +872,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 	 * VFIO device, because this might be the last device and we might need
 	 * to unregister the callback.
 	 */
-	rte_rwlock_read_lock(mem_lock);
+	rte_mcfg_mem_read_lock();
 
 	/* get group number */
 	ret = rte_vfio_get_group_num(sysfs_base, dev_addr, &iommu_group_num);
@@ -947,7 +943,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 	ret = 0;
 
 out:
-	rte_rwlock_read_unlock(mem_lock);
+	rte_mcfg_mem_read_unlock();
 	return ret;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 04/14] eal: add EAL tailq list lock/unlock API
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (3 preceding siblings ...)
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 03/14] lib: " Anatoly Burakov
@ 2019-06-27 11:38   ` Anatoly Burakov
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 05/14] lib: use new tailq locking API Anatoly Burakov
                     ` (9 subsequent siblings)
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:38 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

Currently, locking/unlocking the TAILQ list requires direct
access to the shared memory config. Add an API to do the same.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.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_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 985d36cc2..05167e4dc 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -32,3 +32,31 @@ 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);
 }
+
+void
+rte_mcfg_tailq_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->qlock);
+}
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index a554518ef..240fa150b 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -124,6 +124,30 @@ rte_mcfg_mem_write_lock(void);
 void
 rte_mcfg_mem_write_unlock(void);
 
+/**
+ * Lock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_mcfg_tailq_read_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_mcfg_tailq_read_unlock(void);
+
+/**
+ * Lock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_mcfg_tailq_write_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_mcfg_tailq_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 faad879db..ebdcdf269 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -296,6 +296,10 @@ DPDK_19.08 {
 	rte_mcfg_mem_read_unlock;
 	rte_mcfg_mem_write_lock;
 	rte_mcfg_mem_write_unlock;
+	rte_mcfg_tailq_read_lock;
+	rte_mcfg_tailq_read_unlock;
+	rte_mcfg_tailq_write_lock;
+	rte_mcfg_tailq_write_unlock;
 
 } DPDK_19.05;
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 05/14] lib: use new tailq locking API
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (4 preceding siblings ...)
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 04/14] eal: add EAL tailq list lock/unlock API Anatoly Burakov
@ 2019-06-27 11:39   ` Anatoly Burakov
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 06/14] eal: add new API to lock/unlock mempool list Anatoly Burakov
                     ` (8 subsequent siblings)
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:39 UTC (permalink / raw)
  To: dev
  Cc: Konstantin Ananyev, David Hunt, Byron Marohn,
	Pablo de Lara Guarch, Jerin Jacob, Yipeng Wang, Sameh Gobriel,
	Bruce Richardson, Ferruh Yigit, Vladimir Medvedkin, Olivier Matz,
	Andrew Rybchenko, Reshma Pattan, Gage Eads, david.marchand,
	thomas, stephen

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_acl/rte_acl.c                     | 18 +++++++--------
 lib/librte_distributor/rte_distributor.c     |  4 ++--
 lib/librte_distributor/rte_distributor_v20.c |  4 ++--
 lib/librte_eal/common/eal_common_tailqs.c    |  4 ++--
 lib/librte_efd/rte_efd.c                     | 14 ++++++------
 lib/librte_eventdev/rte_event_ring.c         | 16 ++++++-------
 lib/librte_hash/rte_cuckoo_hash.c            | 16 ++++++-------
 lib/librte_hash/rte_fbk_hash.c               | 14 ++++++------
 lib/librte_kni/rte_kni.c                     | 16 ++++++-------
 lib/librte_lpm/rte_lpm.c                     | 24 ++++++++++----------
 lib/librte_lpm/rte_lpm6.c                    | 14 ++++++------
 lib/librte_member/rte_member.c               | 16 ++++++-------
 lib/librte_mempool/rte_mempool.c             |  8 +++----
 lib/librte_reorder/rte_reorder.c             | 14 ++++++------
 lib/librte_ring/rte_ring.c                   | 18 +++++++--------
 lib/librte_stack/rte_stack.c                 | 18 +++++++--------
 16 files changed, 109 insertions(+), 109 deletions(-)

diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index fd5bd5e4e..7ff11d25f 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -156,13 +156,13 @@ rte_acl_find_existing(const char *name)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, acl_list, next) {
 		ctx = (struct rte_acl_ctx *) te->data;
 		if (strncmp(name, ctx->name, sizeof(ctx->name)) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -182,7 +182,7 @@ rte_acl_free(struct rte_acl_ctx *ctx)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, acl_list, next) {
@@ -190,13 +190,13 @@ rte_acl_free(struct rte_acl_ctx *ctx)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(acl_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(ctx->mem);
 	rte_free(ctx);
@@ -226,7 +226,7 @@ rte_acl_create(const struct rte_acl_param *param)
 	sz = sizeof(*ctx) + param->max_rule_num * param->rule_size;
 
 	/* get EAL TAILQ lock. */
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* if we already have one with that name */
 	TAILQ_FOREACH(te, acl_list, next) {
@@ -268,7 +268,7 @@ rte_acl_create(const struct rte_acl_param *param)
 	}
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return ctx;
 }
 
@@ -377,10 +377,10 @@ rte_acl_list_dump(void)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, acl_list, next) {
 		ctx = (struct rte_acl_ctx *) te->data;
 		rte_acl_dump(ctx);
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 }
diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 208abfb1d..9eb78b330 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -645,9 +645,9 @@ rte_distributor_create_v1705(const char *name,
 					  rte_dist_burst_list);
 
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(dist_burst_list, d, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return d;
 }
diff --git a/lib/librte_distributor/rte_distributor_v20.c b/lib/librte_distributor/rte_distributor_v20.c
index cd5940713..1fc03b971 100644
--- a/lib/librte_distributor/rte_distributor_v20.c
+++ b/lib/librte_distributor/rte_distributor_v20.c
@@ -392,9 +392,9 @@ rte_distributor_create_v20(const char *name,
 	distributor_list = RTE_TAILQ_CAST(rte_distributor_tailq.head,
 					  rte_distributor_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(distributor_list, d, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return d;
 }
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index ca2a7d32a..dc2c13caa 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -58,7 +58,7 @@ rte_dump_tailq(FILE *f)
 
 	mcfg = rte_eal_get_configuration()->mem_config;
 
-	rte_rwlock_read_lock(&mcfg->qlock);
+	rte_mcfg_tailq_read_lock();
 	for (i = 0; i < RTE_MAX_TAILQ; i++) {
 		const struct rte_tailq_head *tailq = &mcfg->tailq_head[i];
 		const struct rte_tailq_entry_head *head = &tailq->tailq_head;
@@ -66,7 +66,7 @@ rte_dump_tailq(FILE *f)
 		fprintf(f, "Tailq %u: qname:<%s>, tqh_first:%p, tqh_last:%p\n",
 			i, tailq->name, head->tqh_first, head->tqh_last);
 	}
-	rte_rwlock_read_unlock(&mcfg->qlock);
+	rte_mcfg_tailq_read_unlock();
 }
 
 static struct rte_tailq_head *
diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index 14e493bc3..b808ce99f 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -532,7 +532,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	num_chunks_shift = rte_bsf32(num_chunks);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/*
 	 * Guarantee there's no existing: this is normally already checked
@@ -685,7 +685,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	te->data = (void *) table;
 	TAILQ_INSERT_TAIL(efd_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	snprintf(ring_name, sizeof(ring_name), "HT_%s", table->name);
 	/* Create ring (Dummy slot index is not enqueued) */
@@ -705,7 +705,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	return table;
 
 error_unlock_exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_efd_free(table);
 
 	return NULL;
@@ -720,7 +720,7 @@ rte_efd_find_existing(const char *name)
 
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, efd_list, next)
 	{
@@ -728,7 +728,7 @@ rte_efd_find_existing(const char *name)
 		if (strncmp(name, table->name, RTE_EFD_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -751,7 +751,7 @@ rte_efd_free(struct rte_efd_table *table)
 		rte_free(table->chunks[socket_id]);
 
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH_SAFE(te, efd_list, next, temp) {
 		if (te->data == (void *) table) {
@@ -761,7 +761,7 @@ rte_efd_free(struct rte_efd_table *table)
 		}
 	}
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_ring_free(table->free_slots);
 	rte_free(table->offline_chunks);
 	rte_free(table->keys);
diff --git a/lib/librte_eventdev/rte_event_ring.c b/lib/librte_eventdev/rte_event_ring.c
index 16d02a953..50190de01 100644
--- a/lib/librte_eventdev/rte_event_ring.c
+++ b/lib/librte_eventdev/rte_event_ring.c
@@ -72,7 +72,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/*
 	 * reserve a memory zone for this ring. If we can't get rte_config or
@@ -89,7 +89,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 			if (rte_memzone_free(mz) != 0)
 				RTE_LOG(ERR, RING, "Cannot free memzone\n");
 			rte_free(te);
-			rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+			rte_mcfg_tailq_write_unlock();
 			return NULL;
 		}
 
@@ -102,7 +102,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return r;
 }
@@ -118,7 +118,7 @@ rte_event_ring_lookup(const char *name)
 	ring_list = RTE_TAILQ_CAST(rte_event_ring_tailq.head,
 			rte_event_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		r = (struct rte_event_ring *) te->data;
@@ -126,7 +126,7 @@ rte_event_ring_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -163,7 +163,7 @@ rte_event_ring_free(struct rte_event_ring *r)
 
 	ring_list = RTE_TAILQ_CAST(rte_event_ring_tailq.head,
 			rte_event_ring_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, ring_list, next) {
@@ -172,13 +172,13 @@ rte_event_ring_free(struct rte_event_ring *r)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(ring_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 }
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 953928f27..865c744d9 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -52,13 +52,13 @@ rte_hash_find_existing(const char *name)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, hash_list, next) {
 		h = (struct rte_hash *) te->data;
 		if (strncmp(name, h->name, RTE_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -239,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	snprintf(hash_name, sizeof(hash_name), "HT_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing: this is normally already checked
 	 * by ring creation above */
@@ -437,11 +437,11 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	te->data = (void *) h;
 	TAILQ_INSERT_TAIL(hash_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return h;
 err_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 err:
 	rte_ring_free(r);
 	rte_ring_free(r_ext);
@@ -466,7 +466,7 @@ rte_hash_free(struct rte_hash *h)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, hash_list, next) {
@@ -475,13 +475,13 @@ rte_hash_free(struct rte_hash *h)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	if (h->use_local_cache)
 		rte_free(h->local_free_slots);
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index 9360f7981..db118c930 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -50,13 +50,13 @@ rte_fbk_hash_find_existing(const char *name)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
 		h = (struct rte_fbk_hash_table *) te->data;
 		if (strncmp(name, h->name, RTE_FBK_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 	if (te == NULL) {
 		rte_errno = ENOENT;
 		return NULL;
@@ -103,7 +103,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 
 	snprintf(hash_name, sizeof(hash_name), "FBK_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -165,7 +165,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 	TAILQ_INSERT_TAIL(fbk_hash_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return ht;
 }
@@ -188,7 +188,7 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -197,13 +197,13 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(fbk_hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(ht);
 	rte_free(te);
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index e29d0cc7d..f6684851c 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -214,7 +214,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	kni = __rte_kni_get(conf->name);
 	if (kni != NULL) {
@@ -304,7 +304,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 	TAILQ_INSERT_TAIL(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	/* Allocate mbufs and then put them into alloc_q */
 	kni_allocate_mbufs(kni);
@@ -318,7 +318,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 kni_fail:
 	rte_free(te);
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return NULL;
 }
@@ -381,7 +381,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, kni_list, next) {
 		if (te->data == kni)
@@ -399,7 +399,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	TAILQ_REMOVE(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	/* mbufs in all fifo should be released, except request/response */
 
@@ -423,7 +423,7 @@ rte_kni_release(struct rte_kni *kni)
 	return 0;
 
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return -1;
 }
@@ -640,11 +640,11 @@ rte_kni_get(const char *name)
 	if (name == NULL || name[0] == '\0')
 		return NULL;
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	kni = __rte_kni_get(name);
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	return kni;
 }
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index 6b7b28a2e..b91f74216 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -97,13 +97,13 @@ rte_lpm_find_existing_v20(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -123,13 +123,13 @@ rte_lpm_find_existing_v1604(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -170,7 +170,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	/* Determine the amount of memory to allocate. */
 	mem_size = sizeof(*lpm) + (sizeof(lpm->rules_tbl[0]) * max_rules);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -212,7 +212,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return lpm;
 }
@@ -247,7 +247,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	tbl8s_size = (sizeof(struct rte_lpm_tbl_entry) *
 			RTE_LPM_TBL8_GROUP_NUM_ENTRIES * config->number_tbl8s);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -315,7 +315,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return lpm;
 }
@@ -339,7 +339,7 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -349,7 +349,7 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm);
 	rte_free(te);
@@ -368,7 +368,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -378,7 +378,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm->tbl8);
 	rte_free(lpm->rules_tbl);
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index a91803113..5af74a539 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -316,7 +316,7 @@ rte_lpm6_create(const char *name, int socket_id,
 	mem_size = sizeof(*lpm) + (sizeof(lpm->tbl8[0]) *
 			RTE_LPM6_TBL8_GROUP_NUM_ENTRIES * config->number_tbl8s);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* Guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -363,11 +363,11 @@ rte_lpm6_create(const char *name, int socket_id,
 	te->data = (void *) lpm;
 
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return lpm;
 
 fail:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 fail_wo_unlock:
 	rte_free(tbl8_hdrs);
@@ -389,13 +389,13 @@ rte_lpm6_find_existing(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = (struct rte_lpm6 *) te->data;
 		if (strncmp(name, l->name, RTE_LPM6_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -420,7 +420,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -431,7 +431,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm->tbl8_hdrs);
 	rte_free(lpm->tbl8_pool);
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index fd228f4ba..efed28dd9 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -32,13 +32,13 @@ rte_member_find_existing(const char *name)
 
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, member_list, next) {
 		setsum = (struct rte_member_setsum *) te->data;
 		if (strncmp(name, setsum->name, RTE_MEMBER_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -56,17 +56,17 @@ rte_member_free(struct rte_member_setsum *setsum)
 	if (setsum == NULL)
 		return;
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_FOREACH(te, member_list, next) {
 		if (te->data == (void *)setsum)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 	TAILQ_REMOVE(member_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	switch (setsum->type) {
 	case RTE_MEMBER_TYPE_HT:
@@ -105,7 +105,7 @@ rte_member_create(const struct rte_member_parameters *params)
 
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, member_list, next) {
 		setsum = te->data;
@@ -159,13 +159,13 @@ rte_member_create(const struct rte_member_parameters *params)
 
 	te->data = (void *)setsum;
 	TAILQ_INSERT_TAIL(member_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return setsum;
 
 error_unlock_exit:
 	rte_free(te);
 	rte_free(setsum);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return NULL;
 }
 
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 69bd2a65c..238287a01 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -711,7 +711,7 @@ rte_mempool_free(struct rte_mempool *mp)
 		return;
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, mempool_list, next) {
 		if (te->data == (void *)mp)
@@ -722,7 +722,7 @@ rte_mempool_free(struct rte_mempool *mp)
 		TAILQ_REMOVE(mempool_list, te, next);
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_mempool_free_memchunks(mp);
 	rte_mempool_ops_free(mp);
@@ -898,9 +898,9 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 
 	te->data = mp;
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(mempool_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
 
 	return mp;
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index 3a4a1b0a0..ae6e3f578 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -119,7 +119,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, reorder_list, next) {
@@ -152,7 +152,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 	}
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return b;
 }
 
@@ -193,7 +193,7 @@ rte_reorder_free(struct rte_reorder_buffer *b)
 
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, reorder_list, next) {
@@ -201,13 +201,13 @@ rte_reorder_free(struct rte_reorder_buffer *b)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(reorder_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_reorder_free_mbufs(b);
 
@@ -229,13 +229,13 @@ rte_reorder_find_existing(const char *name)
 
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, reorder_list, next) {
 		b = (struct rte_reorder_buffer *) te->data;
 		if (strncmp(name, b->name, RTE_REORDER_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index b89ecf999..9ea26a631 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -147,7 +147,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* reserve a memory zone for this ring. If we can't get rte_config or
 	 * we are secondary process, the memzone_reserve function will set
@@ -169,7 +169,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
 		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return r;
 }
@@ -200,7 +200,7 @@ rte_ring_free(struct rte_ring *r)
 	}
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, ring_list, next) {
@@ -209,13 +209,13 @@ rte_ring_free(struct rte_ring *r)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(ring_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 }
@@ -245,13 +245,13 @@ rte_ring_list_dump(FILE *f)
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		rte_ring_dump(f, (struct rte_ring *) te->data);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 }
 
 /* search a ring from its name */
@@ -264,7 +264,7 @@ rte_ring_lookup(const char *name)
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		r = (struct rte_ring *) te->data;
@@ -272,7 +272,7 @@ rte_ring_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index 60f63a65b..2cc7e8e16 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -84,13 +84,13 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	mz = rte_memzone_reserve_aligned(mz_name, sz, socket_id,
 					 0, __alignof__(*s));
 	if (mz == NULL) {
 		STACK_LOG_ERR("Cannot reserve stack memzone!\n");
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		rte_free(te);
 		return NULL;
 	}
@@ -102,7 +102,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 	/* Store the name for later lookups */
 	ret = strlcpy(s->name, name, sizeof(s->name));
 	if (ret < 0 || ret >= (int)sizeof(s->name)) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 
 		rte_errno = ENAMETOOLONG;
 		rte_free(te);
@@ -120,7 +120,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 
 	TAILQ_INSERT_TAIL(stack_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return s;
 }
@@ -135,7 +135,7 @@ rte_stack_free(struct rte_stack *s)
 		return;
 
 	stack_list = RTE_TAILQ_CAST(rte_stack_tailq.head, rte_stack_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, stack_list, next) {
@@ -144,13 +144,13 @@ rte_stack_free(struct rte_stack *s)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(stack_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 
@@ -171,7 +171,7 @@ rte_stack_lookup(const char *name)
 
 	stack_list = RTE_TAILQ_CAST(rte_stack_tailq.head, rte_stack_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, stack_list, next) {
 		r = (struct rte_stack *) te->data;
@@ -179,7 +179,7 @@ rte_stack_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 06/14] eal: add new API to lock/unlock mempool list
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (5 preceding siblings ...)
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 05/14] lib: use new tailq locking API Anatoly Burakov
@ 2019-06-27 11:39   ` Anatoly Burakov
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 07/14] mempool: use new mempool list locking API Anatoly Burakov
                     ` (7 subsequent siblings)
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:39 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

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 <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.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_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 05167e4dc..ba2bc37b7 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -60,3 +60,31 @@ rte_mcfg_tailq_write_unlock(void)
 	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	rte_rwlock_write_unlock(&mcfg->qlock);
 }
+
+void
+rte_mcfg_mempool_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->mplock);
+}
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index 240fa150b..58dcbb96d 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_mcfg_tailq_write_lock(void);
 void
 rte_mcfg_tailq_write_unlock(void);
 
+/**
+ * Lock the internal EAL Mempool list for shared access.
+ */
+void
+rte_mcfg_mempool_read_lock(void);
+
+/**
+ * Unlock the internal EAL Mempool list for shared access.
+ */
+void
+rte_mcfg_mempool_read_unlock(void);
+
+/**
+ * Lock the internal EAL Mempool list for exclusive access.
+ */
+void
+rte_mcfg_mempool_write_lock(void);
+
+/**
+ * Unlock the internal EAL Mempool list for exclusive access.
+ */
+void
+rte_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 ebdcdf269..c28951f65 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -296,6 +296,10 @@ DPDK_19.08 {
 	rte_mcfg_mem_read_unlock;
 	rte_mcfg_mem_write_lock;
 	rte_mcfg_mem_write_unlock;
+	rte_mcfg_mempool_read_lock;
+	rte_mcfg_mempool_read_unlock;
+	rte_mcfg_mempool_write_lock;
+	rte_mcfg_mempool_write_unlock;
 	rte_mcfg_tailq_read_lock;
 	rte_mcfg_tailq_read_unlock;
 	rte_mcfg_tailq_write_lock;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 07/14] mempool: use new mempool list locking API
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (6 preceding siblings ...)
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 06/14] eal: add new API to lock/unlock mempool list Anatoly Burakov
@ 2019-06-27 11:39   ` Anatoly Burakov
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 08/14] eal: remove unused macros Anatoly Burakov
                     ` (6 subsequent siblings)
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:39 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, Andrew Rybchenko, david.marchand, thomas, stephen

Replace usages of direct access to shared memory config with
calls to the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 lib/librte_mempool/rte_mempool.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 238287a01..5c688d456 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -830,7 +830,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_lock();
 
 	/*
 	 * reserve a memory zone for this mempool: private data is
@@ -901,12 +901,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(mempool_list, te, next);
 	rte_mcfg_tailq_write_unlock();
-	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_unlock();
 
 	return mp;
 
 exit_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_unlock();
 	rte_free(te);
 	rte_mempool_free(mp);
 	return NULL;
@@ -1268,14 +1268,14 @@ rte_mempool_list_dump(FILE *f)
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH(te, mempool_list, next) {
 		mp = (struct rte_mempool *) te->data;
 		rte_mempool_dump(f, mp);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 }
 
 /* search a mempool from its name */
@@ -1288,7 +1288,7 @@ rte_mempool_lookup(const char *name)
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH(te, mempool_list, next) {
 		mp = (struct rte_mempool *) te->data;
@@ -1296,7 +1296,7 @@ rte_mempool_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -1315,11 +1315,11 @@ void rte_mempool_walk(void (*func)(struct rte_mempool *, void *),
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH_SAFE(te, mempool_list, next, tmp_te) {
 		(*func)((struct rte_mempool *) te->data, arg);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 08/14] eal: remove unused macros
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (7 preceding siblings ...)
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 07/14] mempool: use new mempool list locking API Anatoly Burakov
@ 2019-06-27 11:39   ` Anatoly Burakov
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 09/14] eal: hide shared memory config Anatoly Burakov
                     ` (5 subsequent siblings)
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:39 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

These macros are not used anymore and can be removed.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/include/rte_eal.h | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index cf701e177..7042672b0 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -449,16 +449,6 @@ typedef void	(*rte_usage_hook_t)(const char * prgname);
 rte_usage_hook_t
 rte_set_application_usage_hook(rte_usage_hook_t usage_func);
 
-/**
- * macro to get the lock of tailq in mem_config
- */
-#define RTE_EAL_TAILQ_RWLOCK         (&rte_eal_get_configuration()->mem_config->qlock)
-
-/**
- * macro to get the multiple lock of mempool shared by multiple-instance
- */
-#define RTE_EAL_MEMPOOL_RWLOCK            (&rte_eal_get_configuration()->mem_config->mplock)
-
 /**
  * Whether EAL is using huge pages (disabled by --no-huge option).
  * The no-huge mode cannot be used with UIO poll-mode drivers like igb/ixgbe.
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 09/14] eal: hide shared memory config
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (8 preceding siblings ...)
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 08/14] eal: remove unused macros Anatoly Burakov
@ 2019-06-27 11:39   ` Anatoly Burakov
  2019-07-04  7:43     ` David Marchand
  2019-07-04 19:51     ` Thomas Monjalon
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 10/14] eal: remove packed attribute from mcfg structure Anatoly Burakov
                     ` (4 subsequent siblings)
  14 siblings, 2 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:39 UTC (permalink / raw)
  To: dev
  Cc: Neil Horman, John McNamara, Marko Kovacevic, Konstantin Ananyev,
	David Hunt, Bruce Richardson, Byron Marohn, Pablo de Lara Guarch,
	Yipeng Wang, Sameh Gobriel, Vladimir Medvedkin, Olivier Matz,
	Andrew Rybchenko, Reshma Pattan, david.marchand, thomas, stephen

Now that everything that has ever accessed the shared memory
config is doing so through the public API's, we can make it
internal. Since we're removing quite a few headers from
rte_eal_memconfig.h, we need to add them back in places
where this header is used.

This bumps the ABI, so also change all build files and make
update documentation.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 app/test/test_memzone.c                       |  1 +
 app/test/test_tailq.c                         |  1 +
 doc/guides/rel_notes/deprecation.rst          |  3 -
 doc/guides/rel_notes/release_19_08.rst        |  8 +-
 drivers/bus/pci/linux/pci_vfio.c              |  1 +
 lib/librte_acl/rte_acl.c                      |  2 +
 lib/librte_distributor/rte_distributor.c      |  1 +
 lib/librte_distributor/rte_distributor_v20.c  |  1 +
 lib/librte_eal/common/eal_common_mcfg.c       |  2 +
 lib/librte_eal/common/eal_common_memory.c     |  1 +
 lib/librte_eal/common/eal_common_memzone.c    |  1 +
 lib/librte_eal/common/eal_common_tailqs.c     |  1 +
 lib/librte_eal/common/eal_memcfg.h            | 79 +++++++++++++++++++
 .../common/include/rte_eal_memconfig.h        | 75 ++----------------
 lib/librte_eal/common/malloc_heap.c           |  2 +
 lib/librte_eal/common/malloc_mp.c             |  1 +
 lib/librte_eal/common/rte_malloc.c            |  1 +
 lib/librte_eal/freebsd/eal/Makefile           |  2 +-
 lib/librte_eal/freebsd/eal/eal_memory.c       |  1 +
 lib/librte_eal/linux/eal/Makefile             |  2 +-
 lib/librte_eal/linux/eal/eal.c                |  1 +
 lib/librte_eal/linux/eal/eal_memalloc.c       |  1 +
 lib/librte_eal/linux/eal/eal_memory.c         |  1 +
 lib/librte_eal/linux/eal/eal_vfio.c           |  1 +
 lib/librte_eal/meson.build                    |  2 +-
 lib/librte_efd/rte_efd.c                      |  1 +
 lib/librte_hash/rte_cuckoo_hash.c             |  1 +
 lib/librte_hash/rte_fbk_hash.c                |  1 +
 lib/librte_lpm/rte_lpm.c                      |  1 +
 lib/librte_lpm/rte_lpm6.c                     |  1 +
 lib/librte_member/rte_member.c                |  1 +
 lib/librte_mempool/rte_mempool.c              |  1 +
 lib/librte_reorder/rte_reorder.c              |  1 +
 lib/librte_ring/rte_ring.c                    |  1 +
 34 files changed, 125 insertions(+), 76 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_memcfg.h

diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index 9fe465e62..7501b63c5 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -19,6 +19,7 @@
 #include <rte_errno.h>
 #include <rte_malloc.h>
 #include "../../lib/librte_eal/common/malloc_elem.h"
+#include "../../lib/librte_eal/common/eal_memcfg.h"
 
 #include "test.h"
 
diff --git a/app/test/test_tailq.c b/app/test/test_tailq.c
index a4ecea2d8..7c9b69fdb 100644
--- a/app/test/test_tailq.c
+++ b/app/test/test_tailq.c
@@ -12,6 +12,7 @@
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
 #include <rte_string_fns.h>
+#include <rte_tailq.h>
 
 #include "test.h"
 
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index e2721fad6..583217da8 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -23,9 +23,6 @@ Deprecation Notices
 * eal: The function ``rte_eal_remote_launch`` will return new error codes
   after read or write error on the pipe, instead of calling ``rte_panic``.
 
-* eal: the ``rte_mem_config`` struct will be made private to remove it from the
-  externally visible ABI and allow it to be updated in the future.
-
 * eal: both declaring and identifying devices will be streamlined in v18.11.
   New functions will appear to query a specific port from buses, classes of
   device and device drivers. Device declaration will be made coherent with the
diff --git a/doc/guides/rel_notes/release_19_08.rst b/doc/guides/rel_notes/release_19_08.rst
index 3da266705..b6314431a 100644
--- a/doc/guides/rel_notes/release_19_08.rst
+++ b/doc/guides/rel_notes/release_19_08.rst
@@ -132,6 +132,10 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+* The ``rte_mem_config`` structure has been made private. The new accessor
+  ``rte_mcfg_*`` functions were introduced to provide replacement for direct
+  access to the shared mem config.
+
 * The network structures, definitions and functions have
   been prefixed by ``rte_`` to resolve conflicts with libc headers.
 
@@ -151,6 +155,8 @@ ABI Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+* The ``rte_mem_config`` structure has been made private.
+
 
 Shared Library Versions
 -----------------------
@@ -184,7 +190,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_compressdev.so.1
      librte_cryptodev.so.7
      librte_distributor.so.1
-     librte_eal.so.10
+   + librte_eal.so.11
      librte_efd.so.1
      librte_ethdev.so.12
      librte_eventdev.so.6
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index ebf6ccd3c..1ceb1c07b 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -20,6 +20,7 @@
 #include <rte_eal.h>
 #include <rte_bus.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "eal_filesystem.h"
 
diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index 7ff11d25f..bd7247cc3 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -4,6 +4,8 @@
 
 #include <rte_string_fns.h>
 #include <rte_acl.h>
+#include <rte_tailq.h>
+
 #include "acl.h"
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 9eb78b330..0a3213bbf 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -14,6 +14,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_private.h"
 #include "rte_distributor.h"
diff --git a/lib/librte_distributor/rte_distributor_v20.c b/lib/librte_distributor/rte_distributor_v20.c
index 1fc03b971..cdc0969a8 100644
--- a/lib/librte_distributor/rte_distributor_v20.c
+++ b/lib/librte_distributor/rte_distributor_v20.c
@@ -13,6 +13,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_v20.h"
 #include "rte_distributor_private.h"
diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index ba2bc37b7..337890a61 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -5,6 +5,8 @@
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
 
+#include "eal_memcfg.h"
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index e73a413cc..b33bc4b29 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -24,6 +24,7 @@
 #include "eal_memalloc.h"
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
+#include "eal_memcfg.h"
 #include "malloc_heap.h"
 
 /*
diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
index 521ad7ca1..ef6c909cb 100644
--- a/lib/librte_eal/common/eal_common_memzone.c
+++ b/lib/librte_eal/common/eal_common_memzone.c
@@ -24,6 +24,7 @@
 #include "malloc_heap.h"
 #include "malloc_elem.h"
 #include "eal_private.h"
+#include "eal_memcfg.h"
 
 static inline const struct rte_memzone *
 memzone_lookup_thread_unsafe(const char *name)
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index dc2c13caa..ead06897b 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -23,6 +23,7 @@
 #include <rte_debug.h>
 
 #include "eal_private.h"
+#include "eal_memcfg.h"
 
 TAILQ_HEAD(rte_tailq_elem_head, rte_tailq_elem);
 /* local tailq list */
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
new file mode 100644
index 000000000..466958352
--- /dev/null
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef EAL_MEMCFG_H
+#define EAL_MEMCFG_H
+
+#include <rte_config.h>
+#include <rte_eal_memconfig.h>
+#include <rte_malloc_heap.h>
+#include <rte_memory.h>
+#include <rte_memzone.h>
+#include <rte_pause.h>
+#include <rte_rwlock.h>
+#include <rte_tailq.h>
+
+/**
+ * the structure for the memory configuration for the RTE.
+ * Used by the rte_config structure. It is separated out, as for multi-process
+ * support, the memory details should be shared across instances
+ */
+struct rte_mem_config {
+	volatile uint32_t magic;   /**< Magic number - Sanity check. */
+
+	/* memory topology */
+	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
+	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
+
+	/**
+	 * current lock nest order
+	 *  - qlock->mlock (ring/hash/lpm)
+	 *  - mplock->qlock->mlock (mempool)
+	 * Notice:
+	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
+	 */
+	rte_rwlock_t mlock;   /**< only used by memzone LIB for thread-safe. */
+	rte_rwlock_t qlock;   /**< used for tailq operation for thread safe. */
+	rte_rwlock_t mplock;  /**< only used by mempool LIB for thread-safe. */
+
+	rte_rwlock_t memory_hotplug_lock;
+	/**< indicates whether memory hotplug request is in progress. */
+
+	/* memory segments and zones */
+	struct rte_fbarray memzones; /**< Memzone descriptors. */
+
+	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
+	/**< list of dynamic arrays holding memsegs */
+
+	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ];
+	/**< Tailqs for objects */
+
+	/* Heaps of Malloc */
+	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
+
+	/* next socket ID for external malloc heap */
+	int next_socket_id;
+
+	/* address of mem_config in primary process. used to map shared config
+	 * into exact same address the primary process maps it.
+	 */
+	uint64_t mem_cfg_addr;
+
+	/* legacy mem and single file segments options are shared */
+	uint32_t legacy_mem;
+	uint32_t single_file_segments;
+
+	/* keeps the more restricted dma mask */
+	uint8_t dma_maskbits;
+} __attribute__((packed));
+
+static inline void
+rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
+{
+	/* wait until shared mem_config finish initialising */
+	while (mcfg->magic != RTE_MAGIC)
+		rte_pause();
+}
+
+#endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index 58dcbb96d..1b615c892 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -5,13 +5,12 @@
 #ifndef _RTE_EAL_MEMCONFIG_H_
 #define _RTE_EAL_MEMCONFIG_H_
 
-#include <rte_config.h>
-#include <rte_tailq.h>
-#include <rte_memory.h>
-#include <rte_memzone.h>
-#include <rte_malloc_heap.h>
-#include <rte_rwlock.h>
-#include <rte_pause.h>
+/**
+ * @file
+ *
+ * This API allows access to EAL shared memory configuration through an API.
+ */
+
 #include <rte_fbarray.h>
 
 #ifdef __cplusplus
@@ -38,68 +37,6 @@ struct rte_memseg_list {
 	struct rte_fbarray memseg_arr;
 };
 
-/**
- * the structure for the memory configuration for the RTE.
- * Used by the rte_config structure. It is separated out, as for multi-process
- * support, the memory details should be shared across instances
- */
-struct rte_mem_config {
-	volatile uint32_t magic;   /**< Magic number - Sanity check. */
-
-	/* memory topology */
-	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
-	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
-
-	/**
-	 * current lock nest order
-	 *  - qlock->mlock (ring/hash/lpm)
-	 *  - mplock->qlock->mlock (mempool)
-	 * Notice:
-	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
-	 */
-	rte_rwlock_t mlock;   /**< only used by memzone LIB for thread-safe. */
-	rte_rwlock_t qlock;   /**< used for tailq operation for thread safe. */
-	rte_rwlock_t mplock;  /**< only used by mempool LIB for thread-safe. */
-
-	rte_rwlock_t memory_hotplug_lock;
-	/**< indicates whether memory hotplug request is in progress. */
-
-	/* memory segments and zones */
-	struct rte_fbarray memzones; /**< Memzone descriptors. */
-
-	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
-	/**< list of dynamic arrays holding memsegs */
-
-	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ]; /**< Tailqs for objects */
-
-	/* Heaps of Malloc */
-	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
-
-	/* next socket ID for external malloc heap */
-	int next_socket_id;
-
-	/* address of mem_config in primary process. used to map shared config into
-	 * exact same address the primary process maps it.
-	 */
-	uint64_t mem_cfg_addr;
-
-	/* legacy mem and single file segments options are shared */
-	uint32_t legacy_mem;
-	uint32_t single_file_segments;
-
-	/* keeps the more restricted dma mask */
-	uint8_t dma_maskbits;
-} __attribute__((__packed__));
-
-
-inline static void
-rte_eal_mcfg_wait_complete(struct rte_mem_config* mcfg)
-{
-	/* wait until shared mem_config finish initialising */
-	while(mcfg->magic != RTE_MAGIC)
-		rte_pause();
-}
-
 /**
  * Lock the internal EAL shared memory configuration for shared access.
  */
diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index f1d31de0d..634ca212f 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -20,11 +20,13 @@
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
 #include <rte_memcpy.h>
+#include <rte_memzone.h>
 #include <rte_atomic.h>
 #include <rte_fbarray.h>
 
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "malloc_elem.h"
 #include "malloc_heap.h"
 #include "malloc_mp.h"
diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c
index 7c6112c4e..1f212f834 100644
--- a/lib/librte_eal/common/malloc_mp.c
+++ b/lib/librte_eal/common/malloc_mp.c
@@ -10,6 +10,7 @@
 #include <rte_string_fns.h>
 
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 
 #include "malloc_elem.h"
 #include "malloc_mp.h"
diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index 98e1bdd07..8d2ef8aeb 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -25,6 +25,7 @@
 #include "malloc_elem.h"
 #include "malloc_heap.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 
 
 /* Free the memory space back to heap */
diff --git a/lib/librte_eal/freebsd/eal/Makefile b/lib/librte_eal/freebsd/eal/Makefile
index dc56af582..0974518ab 100644
--- a/lib/librte_eal/freebsd/eal/Makefile
+++ b/lib/librte_eal/freebsd/eal/Makefile
@@ -22,7 +22,7 @@ LDLIBS += -lrte_kvargs
 
 EXPORT_MAP := ../../rte_eal_version.map
 
-LIBABIVER := 10
+LIBABIVER := 11
 
 # specific to freebsd exec-env
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) := eal.c
diff --git a/lib/librte_eal/freebsd/eal/eal_memory.c b/lib/librte_eal/freebsd/eal/eal_memory.c
index 4b092e1f2..9b9a0577a 100644
--- a/lib/librte_eal/freebsd/eal/eal_memory.c
+++ b/lib/librte_eal/freebsd/eal/eal_memory.c
@@ -18,6 +18,7 @@
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
+#include "eal_memcfg.h"
 
 #define EAL_PAGE_SIZE (sysconf(_SC_PAGESIZE))
 
diff --git a/lib/librte_eal/linux/eal/Makefile b/lib/librte_eal/linux/eal/Makefile
index 3b2642eb8..9c885a9c9 100644
--- a/lib/librte_eal/linux/eal/Makefile
+++ b/lib/librte_eal/linux/eal/Makefile
@@ -10,7 +10,7 @@ ARCH_DIR ?= $(RTE_ARCH)
 EXPORT_MAP := ../../rte_eal_version.map
 VPATH += $(RTE_SDK)/lib/librte_eal/common/arch/$(ARCH_DIR)
 
-LIBABIVER := 10
+LIBABIVER := 11
 
 VPATH += $(RTE_SDK)/lib/librte_eal/common
 
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index d96ed3a7c..1ab4cc769 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -57,6 +57,7 @@
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
+#include "eal_memcfg.h"
 #include "eal_options.h"
 #include "eal_vfio.h"
 
diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c
index 2019636fb..1f6a7c18f 100644
--- a/lib/librte_eal/linux/eal/eal_memalloc.c
+++ b/lib/librte_eal/linux/eal/eal_memalloc.c
@@ -44,6 +44,7 @@
 #include "eal_filesystem.h"
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_private.h"
 
 const int anonymous_hugepages_supported =
diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c
index 1853acea5..9c948a374 100644
--- a/lib/librte_eal/linux/eal/eal_memory.c
+++ b/lib/librte_eal/linux/eal/eal_memory.c
@@ -46,6 +46,7 @@
 
 #include "eal_private.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index 924cba526..5d679ca68 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -15,6 +15,7 @@
 #include <rte_vfio.h>
 
 #include "eal_filesystem.h"
+#include "eal_memcfg.h"
 #include "eal_vfio.h"
 #include "eal_private.h"
 
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index fa36b20e0..5c5023dd4 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -12,7 +12,7 @@ subdir('common') # defines common_sources, common_objs, etc.
 dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env + '/eal')
 
-version = 10  # the version of the EAL API
+version = 11  # the version of the EAL API
 allow_experimental_apis = true
 deps += 'kvargs'
 if dpdk_conf.has('RTE_USE_LIBBSD')
diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index b808ce99f..d3d019578 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -20,6 +20,7 @@
 #include <rte_ring.h>
 #include <rte_jhash.h>
 #include <rte_hash_crc.h>
+#include <rte_tailq.h>
 
 #include "rte_efd.h"
 #if defined(RTE_ARCH_X86)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 865c744d9..b76518b4c 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -27,6 +27,7 @@
 #include <rte_ring.h>
 #include <rte_compat.h>
 #include <rte_vect.h>
+#include <rte_tailq.h>
 
 #include "rte_hash.h"
 #include "rte_cuckoo_hash.h"
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index db118c930..576e8e666 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -20,6 +20,7 @@
 #include <rte_cpuflags.h>
 #include <rte_log.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_fbk_hash.h"
 
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index b91f74216..70c24ac1f 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -21,6 +21,7 @@
 #include <rte_errno.h>
 #include <rte_rwlock.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_lpm.h"
 
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index 5af74a539..9b8aeb972 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -24,6 +24,7 @@
 #include <rte_hash.h>
 #include <assert.h>
 #include <rte_jhash.h>
+#include <rte_tailq.h>
 
 #include "rte_lpm6.h"
 
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index efed28dd9..e0e7f127e 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -10,6 +10,7 @@
 #include <rte_memory.h>
 #include <rte_malloc.h>
 #include <rte_errno.h>
+#include <rte_tailq.h>
 
 #include "rte_member.h"
 #include "rte_member_ht.h"
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 5c688d456..7260ce0be 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -30,6 +30,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_mempool.h"
 
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index ae6e3f578..3c9f0e2d0 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -11,6 +11,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
 #include <rte_malloc.h>
+#include <rte_tailq.h>
 
 #include "rte_reorder.h"
 
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index 9ea26a631..b30b2aa7b 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -30,6 +30,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_ring.h"
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 10/14] eal: remove packed attribute from mcfg structure
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (9 preceding siblings ...)
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 09/14] eal: hide shared memory config Anatoly Burakov
@ 2019-06-27 11:39   ` Anatoly Burakov
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 11/14] eal: uninline wait for mcfg complete function Anatoly Burakov
                     ` (3 subsequent siblings)
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:39 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, thomas, stephen

There is no reason to pack the memconfig structure, and doing so
gives out warnings in some static analyzers. Fix it by removing
the packed attributed.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_memcfg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 466958352..22459a55a 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -66,7 +66,7 @@ struct rte_mem_config {
 
 	/* keeps the more restricted dma mask */
 	uint8_t dma_maskbits;
-} __attribute__((packed));
+};
 
 static inline void
 rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 11/14] eal: uninline wait for mcfg complete function
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (10 preceding siblings ...)
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 10/14] eal: remove packed attribute from mcfg structure Anatoly Burakov
@ 2019-06-27 11:39   ` Anatoly Burakov
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 12/14] eal: unify and move " Anatoly Burakov
                     ` (2 subsequent siblings)
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:39 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, david.marchand, thomas, stephen

Currently, the function to wait until config completion is
static inline for no reason. Move its implementation to
an EAL common file.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 10 ++++++++++
 lib/librte_eal/common/eal_memcfg.h      | 10 +++-------
 lib/librte_eal/freebsd/eal/eal.c        |  3 ++-
 lib/librte_eal/linux/eal/eal.c          |  2 +-
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 337890a61..30969c6bf 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -7,6 +7,16 @@
 
 #include "eal_memcfg.h"
 
+void
+eal_mcfg_wait_complete(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	/* wait until shared mem_config finish initialising */
+	while (mcfg->magic != RTE_MAGIC)
+		rte_pause();
+}
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 22459a55a..7319d9f7a 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -68,12 +68,8 @@ struct rte_mem_config {
 	uint8_t dma_maskbits;
 };
 
-static inline void
-rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
-{
-	/* wait until shared mem_config finish initialising */
-	while (mcfg->magic != RTE_MAGIC)
-		rte_pause();
-}
+/* wait until primary process initialization is complete */
+void
+eal_mcfg_wait_complete(void);
 
 #endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index fac43b017..c102847d1 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -52,6 +52,7 @@
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
 #include "eal_options.h"
+#include "eal_memcfg.h"
 
 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
 
@@ -382,7 +383,7 @@ rte_config_init(void)
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
 			return -1;
-		rte_eal_mcfg_wait_complete(rte_config.mem_config);
+		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
 		break;
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 1ab4cc769..6a06628b1 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -505,7 +505,7 @@ rte_config_init(void)
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
 			return -1;
-		rte_eal_mcfg_wait_complete(rte_config.mem_config);
+		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
 		eal_update_internal_config();
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 12/14] eal: unify and move mcfg complete function
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (11 preceding siblings ...)
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 11/14] eal: uninline wait for mcfg complete function Anatoly Burakov
@ 2019-06-27 11:39   ` Anatoly Burakov
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 13/14] eal: unify internal config initialization Anatoly Burakov
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 14/14] eal: prevent different primary/secondary process versions Anatoly Burakov
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:39 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, david.marchand, thomas, stephen

Currently, mcfg completion function exists in two independent
implementations doing the same thing, which is bug prone.
Unify the two functions and move them into one place.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 14 ++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  4 ++++
 lib/librte_eal/freebsd/eal/eal.c        | 12 +-----------
 lib/librte_eal/linux/eal/eal.c          | 12 +-----------
 4 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 30969c6bf..dc6665d6a 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -5,8 +5,22 @@
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
 
+#include "eal_internal_cfg.h"
 #include "eal_memcfg.h"
 
+void
+eal_mcfg_complete(void)
+{
+	struct rte_config *cfg = rte_eal_get_configuration();
+	struct rte_mem_config *mcfg = cfg->mem_config;
+
+	/* ALL shared mem_config related INIT DONE */
+	if (cfg->process_type == RTE_PROC_PRIMARY)
+		mcfg->magic = RTE_MAGIC;
+
+	internal_config.init_complete = 1;
+}
+
 void
 eal_mcfg_wait_complete(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 7319d9f7a..a2434417e 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -72,4 +72,8 @@ struct rte_mem_config {
 void
 eal_mcfg_wait_complete(void);
 
+/* set mem config as complete */
+void
+eal_mcfg_complete(void);
+
 #endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index c102847d1..13e230fc8 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -632,16 +632,6 @@ sync_func(__attribute__((unused)) void *arg)
 	return 0;
 }
 
-inline static void
-rte_eal_mcfg_complete(void)
-{
-	/* ALL shared mem_config related INIT DONE */
-	if (rte_config.process_type == RTE_PROC_PRIMARY)
-		rte_config.mem_config->magic = RTE_MAGIC;
-
-	internal_config.init_complete = 1;
-}
-
 /* return non-zero if hugepages are enabled. */
 int rte_eal_has_hugepages(void)
 {
@@ -921,7 +911,7 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	rte_eal_mcfg_complete();
+	eal_mcfg_complete();
 
 	/* Call each registered callback, if enabled */
 	rte_option_init();
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 6a06628b1..4fd18b15f 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -933,16 +933,6 @@ sync_func(__attribute__((unused)) void *arg)
 	return 0;
 }
 
-inline static void
-rte_eal_mcfg_complete(void)
-{
-	/* ALL shared mem_config related INIT DONE */
-	if (rte_config.process_type == RTE_PROC_PRIMARY)
-		rte_config.mem_config->magic = RTE_MAGIC;
-
-	internal_config.init_complete = 1;
-}
-
 /*
  * Request iopl privilege for all RPL, returns 0 on success
  * iopl() call is mostly for the i386 architecture. For other architectures,
@@ -1268,7 +1258,7 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	rte_eal_mcfg_complete();
+	eal_mcfg_complete();
 
 	/* Call each registered callback, if enabled */
 	rte_option_init();
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 13/14] eal: unify internal config initialization
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (12 preceding siblings ...)
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 12/14] eal: unify and move " Anatoly Burakov
@ 2019-06-27 11:39   ` Anatoly Burakov
  2019-07-04  7:50     ` David Marchand
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 14/14] eal: prevent different primary/secondary process versions Anatoly Burakov
  14 siblings, 1 reply; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:39 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, david.marchand, thomas, stephen

Currently, each EAL will update internal/shared config in their
own way at init, resulting in needless duplication of code and
OS-dependent behavior. Move the functions to a common file and
add missing FreeBSD steps.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 18 ++++++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  8 ++++++++
 lib/librte_eal/freebsd/eal/eal.c        |  2 ++
 lib/librte_eal/linux/eal/eal.c          | 22 ++--------------------
 4 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index dc6665d6a..fe8d2b726 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -31,6 +31,24 @@ eal_mcfg_wait_complete(void)
 		rte_pause();
 }
 
+void
+eal_mcfg_update_internal(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	internal_config.legacy_mem = mcfg->legacy_mem;
+	internal_config.single_file_segments = mcfg->single_file_segments;
+}
+
+void
+eal_mcfg_update_from_internal(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	mcfg->legacy_mem = internal_config.legacy_mem;
+	mcfg->single_file_segments = internal_config.single_file_segments;
+}
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index a2434417e..d02ac1621 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -68,6 +68,14 @@ struct rte_mem_config {
 	uint8_t dma_maskbits;
 };
 
+/* update internal config from shared mem config */
+void
+eal_mcfg_update_internal(void);
+
+/* update shared mem config from internal config */
+void
+eal_mcfg_update_from_internal(void);
+
 /* wait until primary process initialization is complete */
 void
 eal_mcfg_wait_complete(void);
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 13e230fc8..6bfe203fd 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -379,6 +379,7 @@ rte_config_init(void)
 	case RTE_PROC_PRIMARY:
 		if (rte_eal_config_create() < 0)
 			return -1;
+		eal_mcfg_update_internal();
 		break;
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
@@ -386,6 +387,7 @@ rte_config_init(void)
 		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
+		eal_mcfg_update_from_internal();
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 4fd18b15f..fa205fd29 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -472,24 +472,6 @@ eal_proc_type_detect(void)
 	return ptype;
 }
 
-/* copies data from internal config to shared config */
-static void
-eal_update_mem_config(void)
-{
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	mcfg->legacy_mem = internal_config.legacy_mem;
-	mcfg->single_file_segments = internal_config.single_file_segments;
-}
-
-/* copies data from shared config to internal config */
-static void
-eal_update_internal_config(void)
-{
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	internal_config.legacy_mem = mcfg->legacy_mem;
-	internal_config.single_file_segments = mcfg->single_file_segments;
-}
-
 /* Sets up rte_config structure with the pointer to shared memory config.*/
 static int
 rte_config_init(void)
@@ -500,7 +482,7 @@ rte_config_init(void)
 	case RTE_PROC_PRIMARY:
 		if (rte_eal_config_create() < 0)
 			return -1;
-		eal_update_mem_config();
+		eal_mcfg_update_from_internal();
 		break;
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
@@ -508,7 +490,7 @@ rte_config_init(void)
 		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
-		eal_update_internal_config();
+		eal_mcfg_update_internal();
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v3 14/14] eal: prevent different primary/secondary process versions
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
                     ` (13 preceding siblings ...)
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 13/14] eal: unify internal config initialization Anatoly Burakov
@ 2019-06-27 11:39   ` Anatoly Burakov
  14 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-06-27 11:39 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, david.marchand, thomas, stephen

Currently, nothing stops DPDK to attempt to run primary and
secondary processes while having different versions. This
can lead to all sorts of weird behavior and makes it harder
to maintain compatibility without breaking ABI every once
in a while.

Fix it by explicitly disallowing running different DPDK
versions as primary and secondary processes.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 15 +++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  6 ++++++
 lib/librte_eal/freebsd/eal/eal.c        |  5 ++++-
 lib/librte_eal/linux/eal/eal.c          |  5 ++++-
 4 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index fe8d2b726..1825d9083 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -4,6 +4,7 @@
 
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
+#include <rte_version.h>
 
 #include "eal_internal_cfg.h"
 #include "eal_memcfg.h"
@@ -31,6 +32,18 @@ eal_mcfg_wait_complete(void)
 		rte_pause();
 }
 
+int
+eal_mcfg_check_version(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	/* check if version from memconfig matches compiled in macro */
+	if (mcfg->version != RTE_VERSION)
+		return -1;
+
+	return 0;
+}
+
 void
 eal_mcfg_update_internal(void)
 {
@@ -47,6 +60,8 @@ eal_mcfg_update_from_internal(void)
 
 	mcfg->legacy_mem = internal_config.legacy_mem;
 	mcfg->single_file_segments = internal_config.single_file_segments;
+	/* record current DPDK version */
+	mcfg->version = RTE_VERSION;
 }
 
 void
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index d02ac1621..a3d4b7fd1 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -21,6 +21,8 @@
  */
 struct rte_mem_config {
 	volatile uint32_t magic;   /**< Magic number - Sanity check. */
+	uint32_t version;
+	/**< Prevent secondary processes using different DPDK versions. */
 
 	/* memory topology */
 	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
@@ -80,6 +82,10 @@ eal_mcfg_update_from_internal(void);
 void
 eal_mcfg_wait_complete(void);
 
+/* check if DPDK version of current process matches one stored in the config */
+int
+eal_mcfg_check_version(void);
+
 /* set mem config as complete */
 void
 eal_mcfg_complete(void);
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 6bfe203fd..e2039927c 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -385,6 +385,10 @@ rte_config_init(void)
 		if (rte_eal_config_attach() < 0)
 			return -1;
 		eal_mcfg_wait_complete();
+		if (eal_mcfg_check_version() < 0) {
+			RTE_LOG(ERR, EAL, "Primary and secondary process DPDK version mismatch\n");
+			return -1;
+		}
 		if (rte_eal_config_reattach() < 0)
 			return -1;
 		eal_mcfg_update_from_internal();
@@ -395,7 +399,6 @@ rte_config_init(void)
 			rte_config.process_type);
 		return -1;
 	}
-
 	return 0;
 }
 
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index fa205fd29..5421e934e 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -488,6 +488,10 @@ rte_config_init(void)
 		if (rte_eal_config_attach() < 0)
 			return -1;
 		eal_mcfg_wait_complete();
+		if (eal_mcfg_check_version() < 0) {
+			RTE_LOG(ERR, EAL, "Primary and secondary process DPDK version mismatch\n");
+			return -1;
+		}
 		if (rte_eal_config_reattach() < 0)
 			return -1;
 		eal_mcfg_update_internal();
@@ -498,7 +502,6 @@ rte_config_init(void)
 			rte_config.process_type);
 		return -1;
 	}
-
 	return 0;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 00/14] Make shared memory config non-public
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
@ 2019-06-27 15:36     ` Stephen Hemminger
  2019-07-03  9:38     ` David Marchand
                       ` (9 subsequent siblings)
  10 siblings, 0 replies; 117+ messages in thread
From: Stephen Hemminger @ 2019-06-27 15:36 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, david.marchand, thomas

On Thu, 27 Jun 2019 12:38:55 +0100
Anatoly Burakov <anatoly.burakov@intel.com> wrote:

> This patchset removes the shared memory config from public
> API, and replaces all usages of said config with new API
> calls.
> 
> A lot of the patchset is a search-and-replace job and should
> be pretty easy to review. The rest are pretty trivial EAL
> changes.
> 
> This patchset depends on FreeBSD fixes patchset:
> 
> http://patches.dpdk.org/project/dpdk/list/?series=5196
> 
> v3:
> - Rebase on top of latest master
> 
> v2:
> - Collapsed all changes into fewer patches
> - Addressed review comments
> - Created a new file to store the code
> - Changed namespace to "rte_mcfg_"
> - Added some unification around config init
> - Removed "packed" attribute from mem config
> - Removed unnecessary inlining
> - Added a check to explicitly forbid running multiprocess
>   applications that differ in their DPDK versions
> 
> Anatoly Burakov (14):
>   eal: add API to lock/unlock memory hotplug
>   drivers: use new memory locking API
>   lib: use new memory locking API
>   eal: add EAL tailq list lock/unlock API
>   lib: use new tailq locking API
>   eal: add new API to lock/unlock mempool list
>   mempool: use new mempool list locking API
>   eal: remove unused macros
>   eal: hide shared memory config
>   eal: remove packed attribute from mcfg structure
>   eal: uninline wait for mcfg complete function
>   eal: unify and move mcfg complete function
>   eal: unify internal config initialization
>   eal: prevent different primary/secondary process versions
> 
>  app/test/test_memzone.c                       |   1 +
>  app/test/test_tailq.c                         |   1 +
>  doc/guides/rel_notes/deprecation.rst          |   3 -
>  doc/guides/rel_notes/release_19_08.rst        |   8 +-
>  drivers/bus/fslmc/fslmc_vfio.c                |   8 +-
>  drivers/bus/pci/linux/pci_vfio.c              |   1 +
>  drivers/net/mlx4/mlx4_mr.c                    |  11 +-
>  drivers/net/mlx5/mlx5_mr.c                    |  11 +-
>  .../net/virtio/virtio_user/virtio_user_dev.c  |   7 +-
>  lib/librte_acl/rte_acl.c                      |  20 +--
>  lib/librte_distributor/rte_distributor.c      |   5 +-
>  lib/librte_distributor/rte_distributor_v20.c  |   5 +-
>  lib/librte_eal/common/eal_common_mcfg.c       | 149 ++++++++++++++++++
>  lib/librte_eal/common/eal_common_memory.c     |  44 +++---
>  lib/librte_eal/common/eal_common_memzone.c    |   1 +
>  lib/librte_eal/common/eal_common_tailqs.c     |   5 +-
>  lib/librte_eal/common/eal_memcfg.h            |  93 +++++++++++
>  lib/librte_eal/common/include/rte_eal.h       |  10 --
>  .../common/include/rte_eal_memconfig.h        | 143 +++++++++--------
>  lib/librte_eal/common/malloc_heap.c           |  16 +-
>  lib/librte_eal/common/malloc_mp.c             |   1 +
>  lib/librte_eal/common/meson.build             |   1 +
>  lib/librte_eal/common/rte_malloc.c            |  33 ++--
>  lib/librte_eal/freebsd/eal/Makefile           |   3 +-
>  lib/librte_eal/freebsd/eal/eal.c              |  22 ++-
>  lib/librte_eal/freebsd/eal/eal_memory.c       |   1 +
>  lib/librte_eal/linux/eal/Makefile             |   3 +-
>  lib/librte_eal/linux/eal/eal.c                |  42 ++---
>  lib/librte_eal/linux/eal/eal_memalloc.c       |   1 +
>  lib/librte_eal/linux/eal/eal_memory.c         |   1 +
>  lib/librte_eal/linux/eal/eal_vfio.c           |  17 +-
>  lib/librte_eal/meson.build                    |   2 +-
>  lib/librte_eal/rte_eal_version.map            |  12 ++
>  lib/librte_efd/rte_efd.c                      |  15 +-
>  lib/librte_eventdev/rte_event_ring.c          |  16 +-
>  lib/librte_hash/rte_cuckoo_hash.c             |  17 +-
>  lib/librte_hash/rte_fbk_hash.c                |  15 +-
>  lib/librte_kni/rte_kni.c                      |  16 +-
>  lib/librte_lpm/rte_lpm.c                      |  25 +--
>  lib/librte_lpm/rte_lpm6.c                     |  15 +-
>  lib/librte_member/rte_member.c                |  17 +-
>  lib/librte_mempool/rte_mempool.c              |  27 ++--
>  lib/librte_reorder/rte_reorder.c              |  15 +-
>  lib/librte_ring/rte_ring.c                    |  19 +--
>  lib/librte_stack/rte_stack.c                  |  18 +--
>  45 files changed, 566 insertions(+), 330 deletions(-)
>  create mode 100644 lib/librte_eal/common/eal_common_mcfg.c
>  create mode 100644 lib/librte_eal/common/eal_memcfg.h
> 

This looks good thanks.

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v2 02/14] drivers: use new memory locking API
  2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 02/14] drivers: use new memory locking API Anatoly Burakov
  2019-06-27  9:24   ` Hemant Agrawal
@ 2019-06-28 15:21   ` Yongseok Koh
  1 sibling, 0 replies; 117+ messages in thread
From: Yongseok Koh @ 2019-06-28 15:21 UTC (permalink / raw)
  To: Anatoly Burakov
  Cc: dev, Hemant Agrawal, Shreyansh Jain, Matan Azrad, Shahaf Shuler,
	Maxime Coquelin, Tiwei Bie, Zhihong Wang, david.marchand,
	Thomas Monjalon, stephen


> On Jun 25, 2019, at 9:05 AM, Anatoly Burakov <anatoly.burakov@intel.com> wrote:
> 
> Replace usages of direct access to shared memory config with
> calls to the new API.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
> drivers/bus/fslmc/fslmc_vfio.c                   |  8 +++-----
> drivers/net/mlx4/mlx4_mr.c                       | 11 +++++------
> drivers/net/mlx5/mlx5_mr.c                       | 11 +++++------

For mlx4/5 PMDs,
Acked-by: Yongseok Koh <yskoh@mellanox.com>

> drivers/net/virtio/virtio_user/virtio_user_dev.c |  7 +++----
> 4 files changed, 16 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
> index 1aae56fa9..44e4fa6e2 100644
> --- a/drivers/bus/fslmc/fslmc_vfio.c
> +++ b/drivers/bus/fslmc/fslmc_vfio.c
> @@ -347,14 +347,12 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,
> int rte_fslmc_vfio_dmamap(void)
> {
> 	int i = 0, ret;
> -	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
> -	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
> 
> 	/* Lock before parsing and registering callback to memory subsystem */
> -	rte_rwlock_read_lock(mem_lock);
> +	rte_mcfg_mem_read_lock();
> 
> 	if (rte_memseg_walk(fslmc_dmamap_seg, &i) < 0) {
> -		rte_rwlock_read_unlock(mem_lock);
> +		rte_mcfg_mem_read_unlock();
> 		return -1;
> 	}
> 
> @@ -378,7 +376,7 @@ int rte_fslmc_vfio_dmamap(void)
> 	/* Existing segments have been mapped and memory callback for hotplug
> 	 * has been installed.
> 	 */
> -	rte_rwlock_read_unlock(mem_lock);
> +	rte_mcfg_mem_read_unlock();
> 
> 	return 0;
> }
> diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
> index 48d458ad4..80827ce75 100644
> --- a/drivers/net/mlx4/mlx4_mr.c
> +++ b/drivers/net/mlx4/mlx4_mr.c
> @@ -593,7 +593,6 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
> 		       uintptr_t addr)
> {
> 	struct mlx4_priv *priv = dev->data->dev_private;
> -	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
> 	const struct rte_memseg_list *msl;
> 	const struct rte_memseg *ms;
> 	struct mlx4_mr *mr = NULL;
> @@ -696,7 +695,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
> 	 * just single page. If not, go on with the big chunk atomically from
> 	 * here.
> 	 */
> -	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
> +	rte_mcfg_mem_read_lock();
> 	data_re = data;
> 	if (len > msl->page_sz &&
> 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
> @@ -714,7 +713,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
> 		 */
> 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
> 		data.end = data.start + msl->page_sz;
> -		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
> +		rte_mcfg_mem_read_unlock();
> 		mr_free(mr);
> 		goto alloc_resources;
> 	}
> @@ -734,7 +733,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
> 		DEBUG("port %u found MR for %p on final lookup, abort",
> 		      dev->data->port_id, (void *)addr);
> 		rte_rwlock_write_unlock(&priv->mr.rwlock);
> -		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
> +		rte_mcfg_mem_read_unlock();
> 		/*
> 		 * Must be unlocked before calling rte_free() because
> 		 * mlx4_mr_mem_event_free_cb() can be called inside.
> @@ -802,12 +801,12 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
> 	/* Lookup can't fail. */
> 	assert(entry->lkey != UINT32_MAX);
> 	rte_rwlock_write_unlock(&priv->mr.rwlock);
> -	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
> +	rte_mcfg_mem_read_unlock();
> 	return entry->lkey;
> err_mrlock:
> 	rte_rwlock_write_unlock(&priv->mr.rwlock);
> err_memlock:
> -	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
> +	rte_mcfg_mem_read_unlock();
> err_nolock:
> 	/*
> 	 * In case of error, as this can be called in a datapath, a warning
> diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
> index 66e8e874e..872d0591e 100644
> --- a/drivers/net/mlx5/mlx5_mr.c
> +++ b/drivers/net/mlx5/mlx5_mr.c
> @@ -580,7 +580,6 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
> 	struct mlx5_priv *priv = dev->data->dev_private;
> 	struct mlx5_ibv_shared *sh = priv->sh;
> 	struct mlx5_dev_config *config = &priv->config;
> -	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
> 	const struct rte_memseg_list *msl;
> 	const struct rte_memseg *ms;
> 	struct mlx5_mr *mr = NULL;
> @@ -684,7 +683,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
> 	 * just single page. If not, go on with the big chunk atomically from
> 	 * here.
> 	 */
> -	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
> +	rte_mcfg_mem_read_lock();
> 	data_re = data;
> 	if (len > msl->page_sz &&
> 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
> @@ -702,7 +701,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
> 		 */
> 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
> 		data.end = data.start + msl->page_sz;
> -		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
> +		rte_mcfg_mem_read_unlock();
> 		mr_free(mr);
> 		goto alloc_resources;
> 	}
> @@ -722,7 +721,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
> 		DEBUG("port %u found MR for %p on final lookup, abort",
> 		      dev->data->port_id, (void *)addr);
> 		rte_rwlock_write_unlock(&sh->mr.rwlock);
> -		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
> +		rte_mcfg_mem_read_unlock();
> 		/*
> 		 * Must be unlocked before calling rte_free() because
> 		 * mlx5_mr_mem_event_free_cb() can be called inside.
> @@ -790,12 +789,12 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
> 	/* Lookup can't fail. */
> 	assert(entry->lkey != UINT32_MAX);
> 	rte_rwlock_write_unlock(&sh->mr.rwlock);
> -	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
> +	rte_mcfg_mem_read_unlock();
> 	return entry->lkey;
> err_mrlock:
> 	rte_rwlock_write_unlock(&sh->mr.rwlock);
> err_memlock:
> -	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
> +	rte_mcfg_mem_read_unlock();
> err_nolock:
> 	/*
> 	 * In case of error, as this can be called in a datapath, a warning
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index e743695e4..c3ab9a21d 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -125,7 +125,6 @@ is_vhost_user_by_type(const char *path)
> int
> virtio_user_start_device(struct virtio_user_dev *dev)
> {
> -	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
> 	uint64_t features;
> 	int ret;
> 
> @@ -142,7 +141,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)
> 	 * replaced when we get proper supports from the
> 	 * memory subsystem in the future.
> 	 */
> -	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
> +	rte_mcfg_mem_read_lock();
> 	pthread_mutex_lock(&dev->mutex);
> 
> 	if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0)
> @@ -180,12 +179,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
> 
> 	dev->started = true;
> 	pthread_mutex_unlock(&dev->mutex);
> -	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
> +	rte_mcfg_mem_read_unlock();
> 
> 	return 0;
> error:
> 	pthread_mutex_unlock(&dev->mutex);
> -	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
> +	rte_mcfg_mem_read_unlock();
> 	/* TODO: free resource here or caller to check */
> 	return -1;
> }
> -- 
> 2.17.1


^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 00/14] Make shared memory config non-public
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
  2019-06-27 15:36     ` Stephen Hemminger
@ 2019-07-03  9:38     ` David Marchand
  2019-07-03 10:47       ` Burakov, Anatoly
  2019-07-04  8:09       ` David Marchand
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
                       ` (8 subsequent siblings)
  10 siblings, 2 replies; 117+ messages in thread
From: David Marchand @ 2019-07-03  9:38 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Thomas Monjalon, Stephen Hemminger

Hello Anatoly,

On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov <anatoly.burakov@intel.com>
wrote:

> This patchset removes the shared memory config from public
> API, and replaces all usages of said config with new API
> calls.
>
> A lot of the patchset is a search-and-replace job and should
> be pretty easy to review. The rest are pretty trivial EAL
> changes.
>
> This patchset depends on FreeBSD fixes patchset:
>
> http://patches.dpdk.org/project/dpdk/list/?series=5196
>
> v3:
> - Rebase on top of latest master
>
> v2:
> - Collapsed all changes into fewer patches
> - Addressed review comments
> - Created a new file to store the code
> - Changed namespace to "rte_mcfg_"
> - Added some unification around config init
> - Removed "packed" attribute from mem config
> - Removed unnecessary inlining
> - Added a check to explicitly forbid running multiprocess
>   applications that differ in their DPDK versions
>


For the parts I already had a look at, I still think the changes are in too
many patches.
A lot of this is just search/replace we can have it with the patch that
introduces it.
- patch 1, 2 and 3 could be squashed as a single one (plus removing the
unused macro from patch 8)
- idem with patch 4 and 5
- idem with patch 6 and 7 (plus removing the unused macro from patch 8)


I will look at the rest tomorrow (hopefully).

-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 00/14] Make shared memory config non-public
  2019-07-03  9:38     ` David Marchand
@ 2019-07-03 10:47       ` Burakov, Anatoly
  2019-07-04  8:09       ` David Marchand
  1 sibling, 0 replies; 117+ messages in thread
From: Burakov, Anatoly @ 2019-07-03 10:47 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Thomas Monjalon, Stephen Hemminger

On 03-Jul-19 10:38 AM, David Marchand wrote:
> Hello Anatoly,
> 
> On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov 
> <anatoly.burakov@intel.com <mailto:anatoly.burakov@intel.com>> wrote:
> 
>     This patchset removes the shared memory config from public
>     API, and replaces all usages of said config with new API
>     calls.
> 
>     A lot of the patchset is a search-and-replace job and should
>     be pretty easy to review. The rest are pretty trivial EAL
>     changes.
> 
>     This patchset depends on FreeBSD fixes patchset:
> 
>     http://patches.dpdk.org/project/dpdk/list/?series=5196
> 
>     v3:
>     - Rebase on top of latest master
> 
>     v2:
>     - Collapsed all changes into fewer patches
>     - Addressed review comments
>     - Created a new file to store the code
>     - Changed namespace to "rte_mcfg_"
>     - Added some unification around config init
>     - Removed "packed" attribute from mem config
>     - Removed unnecessary inlining
>     - Added a check to explicitly forbid running multiprocess
>        applications that differ in their DPDK versions
> 
> 
> 
> For the parts I already had a look at, I still think the changes are in 
> too many patches.
> A lot of this is just search/replace we can have it with the patch that 
> introduces it.
> - patch 1, 2 and 3 could be squashed as a single one (plus removing the 
> unused macro from patch 8)
> - idem with patch 4 and 5
> - idem with patch 6 and 7 (plus removing the unused macro from patch 8)
> 
> 
> I will look at the rest tomorrow (hopefully).
> 
> -- 
> David Marchand

Sure, i can squash it down into single patches for search/replace if 
that's the preference.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 09/14] eal: hide shared memory config
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 09/14] eal: hide shared memory config Anatoly Burakov
@ 2019-07-04  7:43     ` David Marchand
  2019-07-04 10:47       ` Burakov, Anatoly
  2019-07-04 19:51     ` Thomas Monjalon
  1 sibling, 1 reply; 117+ messages in thread
From: David Marchand @ 2019-07-04  7:43 UTC (permalink / raw)
  To: Anatoly Burakov
  Cc: dev, Neil Horman, John McNamara, Marko Kovacevic,
	Konstantin Ananyev, David Hunt, Bruce Richardson, Byron Marohn,
	Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Reshma Pattan, Thomas Monjalon, Stephen Hemminger

On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov <anatoly.burakov@intel.com>
wrote:

> diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h
> b/lib/librte_eal/common/include/rte_eal_memconfig.h
> index 58dcbb96d..1b615c892 100644
> --- a/lib/librte_eal/common/include/rte_eal_memconfig.h
> +++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
> @@ -5,13 +5,12 @@
>  #ifndef _RTE_EAL_MEMCONFIG_H_
>  #define _RTE_EAL_MEMCONFIG_H_
>
> -#include <rte_config.h>
> -#include <rte_tailq.h>
> -#include <rte_memory.h>
> -#include <rte_memzone.h>
> -#include <rte_malloc_heap.h>
> -#include <rte_rwlock.h>
> -#include <rte_pause.h>
> +/**
> + * @file
> + *
> + * This API allows access to EAL shared memory configuration through an
> API.
> + */
> +
>  #include <rte_fbarray.h>
>
>  #ifdef __cplusplus
> @@ -38,68 +37,6 @@ struct rte_memseg_list {
>         struct rte_fbarray memseg_arr;
>  };
>
>
You left the rte_memseg_list definition here and the inclusion of
rte_fbarray.h.
Is this intentional?

I would expect it to be defined in a header like rte_memory.h.
If you agree, this could be done in a follow-up patch.



-/**
> - * the structure for the memory configuration for the RTE.
> - * Used by the rte_config structure. It is separated out, as for
> multi-process
> - * support, the memory details should be shared across instances
> - */
> -struct rte_mem_config {
> -       volatile uint32_t magic;   /**< Magic number - Sanity check. */
> -
> -       /* memory topology */
> -       uint32_t nchannel;    /**< Number of channels (0 if unknown). */
> -       uint32_t nrank;       /**< Number of ranks (0 if unknown). */
> -
> -       /**
> -        * current lock nest order
> -        *  - qlock->mlock (ring/hash/lpm)
> -        *  - mplock->qlock->mlock (mempool)
> -        * Notice:
> -        *  *ALWAYS* obtain qlock first if having to obtain both qlock and
> mlock
> -        */
> -       rte_rwlock_t mlock;   /**< only used by memzone LIB for
> thread-safe. */
> -       rte_rwlock_t qlock;   /**< used for tailq operation for thread
> safe. */
> -       rte_rwlock_t mplock;  /**< only used by mempool LIB for
> thread-safe. */
> -
> -       rte_rwlock_t memory_hotplug_lock;
> -       /**< indicates whether memory hotplug request is in progress. */
> -
> -       /* memory segments and zones */
> -       struct rte_fbarray memzones; /**< Memzone descriptors. */
> -
> -       struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
> -       /**< list of dynamic arrays holding memsegs */
> -
> -       struct rte_tailq_head tailq_head[RTE_MAX_TAILQ]; /**< Tailqs for
> objects */
> -
> -       /* Heaps of Malloc */
> -       struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
> -
> -       /* next socket ID for external malloc heap */
> -       int next_socket_id;
> -
> -       /* address of mem_config in primary process. used to map shared
> config into
> -        * exact same address the primary process maps it.
> -        */
> -       uint64_t mem_cfg_addr;
> -
> -       /* legacy mem and single file segments options are shared */
> -       uint32_t legacy_mem;
> -       uint32_t single_file_segments;
> -
> -       /* keeps the more restricted dma mask */
> -       uint8_t dma_maskbits;
> -} __attribute__((__packed__));
> -
> -
> -inline static void
> -rte_eal_mcfg_wait_complete(struct rte_mem_config* mcfg)
> -{
> -       /* wait until shared mem_config finish initialising */
> -       while(mcfg->magic != RTE_MAGIC)
> -               rte_pause();
> -}
> -
>  /**
>   * Lock the internal EAL shared memory configuration for shared access.
>   */
>

-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 13/14] eal: unify internal config initialization
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 13/14] eal: unify internal config initialization Anatoly Burakov
@ 2019-07-04  7:50     ` David Marchand
  2019-07-04  7:56       ` David Marchand
  0 siblings, 1 reply; 117+ messages in thread
From: David Marchand @ 2019-07-04  7:50 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Bruce Richardson, Thomas Monjalon, Stephen Hemminger

On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov <anatoly.burakov@intel.com>
wrote:

> Currently, each EAL will update internal/shared config in their
> own way at init, resulting in needless duplication of code and
> OS-dependent behavior. Move the functions to a common file and
> add missing FreeBSD steps.
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  lib/librte_eal/common/eal_common_mcfg.c | 18 ++++++++++++++++++
>  lib/librte_eal/common/eal_memcfg.h      |  8 ++++++++
>  lib/librte_eal/freebsd/eal/eal.c        |  2 ++
>  lib/librte_eal/linux/eal/eal.c          | 22 ++--------------------
>  4 files changed, 30 insertions(+), 20 deletions(-)
>
> diff --git a/lib/librte_eal/common/eal_common_mcfg.c
> b/lib/librte_eal/common/eal_common_mcfg.c
> index dc6665d6a..fe8d2b726 100644
> --- a/lib/librte_eal/common/eal_common_mcfg.c
> +++ b/lib/librte_eal/common/eal_common_mcfg.c
> @@ -31,6 +31,24 @@ eal_mcfg_wait_complete(void)
>                 rte_pause();
>  }
>
> +void
> +eal_mcfg_update_internal(void)
> +{
> +       struct rte_mem_config *mcfg =
> rte_eal_get_configuration()->mem_config;
> +
> +       internal_config.legacy_mem = mcfg->legacy_mem;
> +       internal_config.single_file_segments = mcfg->single_file_segments;
> +}
> +
> +void
> +eal_mcfg_update_from_internal(void)
> +{
> +       struct rte_mem_config *mcfg =
> rte_eal_get_configuration()->mem_config;
> +
> +       mcfg->legacy_mem = internal_config.legacy_mem;
> +       mcfg->single_file_segments = internal_config.single_file_segments;
> +}
> +
>  void
>  rte_mcfg_mem_read_lock(void)
>  {
> diff --git a/lib/librte_eal/common/eal_memcfg.h
> b/lib/librte_eal/common/eal_memcfg.h
> index a2434417e..d02ac1621 100644
> --- a/lib/librte_eal/common/eal_memcfg.h
> +++ b/lib/librte_eal/common/eal_memcfg.h
> @@ -68,6 +68,14 @@ struct rte_mem_config {
>         uint8_t dma_maskbits;
>  };
>
> +/* update internal config from shared mem config */
> +void
> +eal_mcfg_update_internal(void);
> +
> +/* update shared mem config from internal config */
> +void
> +eal_mcfg_update_from_internal(void);
> +
>  /* wait until primary process initialization is complete */
>  void
>  eal_mcfg_wait_complete(void);
> diff --git a/lib/librte_eal/freebsd/eal/eal.c
> b/lib/librte_eal/freebsd/eal/eal.c
> index 13e230fc8..6bfe203fd 100644
> --- a/lib/librte_eal/freebsd/eal/eal.c
> +++ b/lib/librte_eal/freebsd/eal/eal.c
> @@ -379,6 +379,7 @@ rte_config_init(void)
>         case RTE_PROC_PRIMARY:
>                 if (rte_eal_config_create() < 0)
>                         return -1;
> +               eal_mcfg_update_internal();
>                 break;
>         case RTE_PROC_SECONDARY:
>                 if (rte_eal_config_attach() < 0)
> @@ -386,6 +387,7 @@ rte_config_init(void)
>                 eal_mcfg_wait_complete();
>                 if (rte_eal_config_reattach() < 0)
>                         return -1;
> +               eal_mcfg_update_from_internal();
>                 break;
>         case RTE_PROC_AUTO:
>         case RTE_PROC_INVALID:
>


Hum, you swapped eal_mcfg_update_internal and eal_mcfg_update_from_internal.
The names are a bit ambiguous, and I wonder if we really need those
separate helpers.

rte_eal_config_create and rte_eal_config_attach are already awfully close
in linux and freebsd implementation.
Can't we have them as common code and put those helpers bits direct in them
?




> diff --git a/lib/librte_eal/linux/eal/eal.c
> b/lib/librte_eal/linux/eal/eal.c
> index 4fd18b15f..fa205fd29 100644
> --- a/lib/librte_eal/linux/eal/eal.c
> +++ b/lib/librte_eal/linux/eal/eal.c
> @@ -472,24 +472,6 @@ eal_proc_type_detect(void)
>         return ptype;
>  }
>
> -/* copies data from internal config to shared config */
> -static void
> -eal_update_mem_config(void)
> -{
> -       struct rte_mem_config *mcfg =
> rte_eal_get_configuration()->mem_config;
> -       mcfg->legacy_mem = internal_config.legacy_mem;
> -       mcfg->single_file_segments = internal_config.single_file_segments;
> -}
> -
> -/* copies data from shared config to internal config */
> -static void
> -eal_update_internal_config(void)
> -{
> -       struct rte_mem_config *mcfg =
> rte_eal_get_configuration()->mem_config;
> -       internal_config.legacy_mem = mcfg->legacy_mem;
> -       internal_config.single_file_segments = mcfg->single_file_segments;
> -}
> -
>  /* Sets up rte_config structure with the pointer to shared memory
> config.*/
>  static int
>  rte_config_init(void)
> @@ -500,7 +482,7 @@ rte_config_init(void)
>         case RTE_PROC_PRIMARY:
>                 if (rte_eal_config_create() < 0)
>                         return -1;
> -               eal_update_mem_config();
> +               eal_mcfg_update_from_internal();
>                 break;
>         case RTE_PROC_SECONDARY:
>                 if (rte_eal_config_attach() < 0)
> @@ -508,7 +490,7 @@ rte_config_init(void)
>                 eal_mcfg_wait_complete();
>                 if (rte_eal_config_reattach() < 0)
>                         return -1;
> -               eal_update_internal_config();
> +               eal_mcfg_update_internal();
>                 break;
>         case RTE_PROC_AUTO:
>         case RTE_PROC_INVALID:
> --
> 2.17.1
>


-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 13/14] eal: unify internal config initialization
  2019-07-04  7:50     ` David Marchand
@ 2019-07-04  7:56       ` David Marchand
  2019-07-04 10:50         ` Burakov, Anatoly
  0 siblings, 1 reply; 117+ messages in thread
From: David Marchand @ 2019-07-04  7:56 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Bruce Richardson, Thomas Monjalon, Stephen Hemminger

On Thu, Jul 4, 2019 at 9:50 AM David Marchand <david.marchand@redhat.com>
wrote:

>
>
> On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov <anatoly.burakov@intel.com>
> wrote:
>
>> Currently, each EAL will update internal/shared config in their
>> own way at init, resulting in needless duplication of code and
>> OS-dependent behavior. Move the functions to a common file and
>> add missing FreeBSD steps.
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>> ---
>>  lib/librte_eal/common/eal_common_mcfg.c | 18 ++++++++++++++++++
>>  lib/librte_eal/common/eal_memcfg.h      |  8 ++++++++
>>  lib/librte_eal/freebsd/eal/eal.c        |  2 ++
>>  lib/librte_eal/linux/eal/eal.c          | 22 ++--------------------
>>  4 files changed, 30 insertions(+), 20 deletions(-)
>>
>> diff --git a/lib/librte_eal/common/eal_common_mcfg.c
>> b/lib/librte_eal/common/eal_common_mcfg.c
>> index dc6665d6a..fe8d2b726 100644
>> --- a/lib/librte_eal/common/eal_common_mcfg.c
>> +++ b/lib/librte_eal/common/eal_common_mcfg.c
>> @@ -31,6 +31,24 @@ eal_mcfg_wait_complete(void)
>>                 rte_pause();
>>  }
>>
>> +void
>> +eal_mcfg_update_internal(void)
>> +{
>> +       struct rte_mem_config *mcfg =
>> rte_eal_get_configuration()->mem_config;
>> +
>> +       internal_config.legacy_mem = mcfg->legacy_mem;
>> +       internal_config.single_file_segments = mcfg->single_file_segments;
>> +}
>> +
>> +void
>> +eal_mcfg_update_from_internal(void)
>> +{
>> +       struct rte_mem_config *mcfg =
>> rte_eal_get_configuration()->mem_config;
>> +
>> +       mcfg->legacy_mem = internal_config.legacy_mem;
>> +       mcfg->single_file_segments = internal_config.single_file_segments;
>> +}
>> +
>>  void
>>  rte_mcfg_mem_read_lock(void)
>>  {
>> diff --git a/lib/librte_eal/common/eal_memcfg.h
>> b/lib/librte_eal/common/eal_memcfg.h
>> index a2434417e..d02ac1621 100644
>> --- a/lib/librte_eal/common/eal_memcfg.h
>> +++ b/lib/librte_eal/common/eal_memcfg.h
>> @@ -68,6 +68,14 @@ struct rte_mem_config {
>>         uint8_t dma_maskbits;
>>  };
>>
>> +/* update internal config from shared mem config */
>> +void
>> +eal_mcfg_update_internal(void);
>> +
>> +/* update shared mem config from internal config */
>> +void
>> +eal_mcfg_update_from_internal(void);
>> +
>>  /* wait until primary process initialization is complete */
>>  void
>>  eal_mcfg_wait_complete(void);
>> diff --git a/lib/librte_eal/freebsd/eal/eal.c
>> b/lib/librte_eal/freebsd/eal/eal.c
>> index 13e230fc8..6bfe203fd 100644
>> --- a/lib/librte_eal/freebsd/eal/eal.c
>> +++ b/lib/librte_eal/freebsd/eal/eal.c
>> @@ -379,6 +379,7 @@ rte_config_init(void)
>>         case RTE_PROC_PRIMARY:
>>                 if (rte_eal_config_create() < 0)
>>                         return -1;
>> +               eal_mcfg_update_internal();
>>                 break;
>>         case RTE_PROC_SECONDARY:
>>                 if (rte_eal_config_attach() < 0)
>> @@ -386,6 +387,7 @@ rte_config_init(void)
>>                 eal_mcfg_wait_complete();
>>                 if (rte_eal_config_reattach() < 0)
>>                         return -1;
>> +               eal_mcfg_update_from_internal();
>>                 break;
>>         case RTE_PROC_AUTO:
>>         case RTE_PROC_INVALID:
>>
>
>
> Hum, you swapped eal_mcfg_update_internal and
> eal_mcfg_update_from_internal.
> The names are a bit ambiguous, and I wonder if we really need those
> separate helpers.
>

Replying to myself... at least those helpers try to do something
explicitly: synchronising the local copy of the configuration with the
shared mem config.
Keeping them separate documents this step.

Anyway, your choice, but you must fix freebsd :-)


-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 00/14] Make shared memory config non-public
  2019-07-03  9:38     ` David Marchand
  2019-07-03 10:47       ` Burakov, Anatoly
@ 2019-07-04  8:09       ` David Marchand
  2019-07-04 19:52         ` Thomas Monjalon
  1 sibling, 1 reply; 117+ messages in thread
From: David Marchand @ 2019-07-04  8:09 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Thomas Monjalon, Stephen Hemminger

On Wed, Jul 3, 2019 at 11:38 AM David Marchand <david.marchand@redhat.com>
wrote:

> Hello Anatoly,
>
> On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov <anatoly.burakov@intel.com>
> wrote:
>
>> This patchset removes the shared memory config from public
>> API, and replaces all usages of said config with new API
>> calls.
>>
>> A lot of the patchset is a search-and-replace job and should
>> be pretty easy to review. The rest are pretty trivial EAL
>> changes.
>>
>> This patchset depends on FreeBSD fixes patchset:
>>
>> http://patches.dpdk.org/project/dpdk/list/?series=5196
>>
>> v3:
>> - Rebase on top of latest master
>>
>> v2:
>> - Collapsed all changes into fewer patches
>> - Addressed review comments
>> - Created a new file to store the code
>> - Changed namespace to "rte_mcfg_"
>> - Added some unification around config init
>> - Removed "packed" attribute from mem config
>> - Removed unnecessary inlining
>> - Added a check to explicitly forbid running multiprocess
>>   applications that differ in their DPDK versions
>>
>
>
> For the parts I already had a look at, I still think the changes are in
> too many patches.
> A lot of this is just search/replace we can have it with the patch that
> introduces it.
> - patch 1, 2 and 3 could be squashed as a single one (plus removing the
> unused macro from patch 8)
> - idem with patch 4 and 5
> - idem with patch 6 and 7 (plus removing the unused macro from patch 8)
>
>
Overall, I am ok with the changes, once the patch 13 is fixed.
You can add my ack on the n+1 patchset.


I just want to state two approaches to merge these changes:
- the first one would be to split this series in two
  - take the first part of this series now, but mark the new API
"experimental"
  - postpone the merge to 19.11 of the second part, which starts at the
hiding rte_mem_config patch
- the second one is taking these changes in one go

The second one is the quicker and the more straightforward but it leaves
the risk of having missed something and we must break the ABI again in
19.11.
The risk is quite low, given the changes.


Thomas, comments?

-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 09/14] eal: hide shared memory config
  2019-07-04  7:43     ` David Marchand
@ 2019-07-04 10:47       ` Burakov, Anatoly
  2019-07-04 10:52         ` David Marchand
  0 siblings, 1 reply; 117+ messages in thread
From: Burakov, Anatoly @ 2019-07-04 10:47 UTC (permalink / raw)
  To: David Marchand
  Cc: dev, Neil Horman, John McNamara, Marko Kovacevic,
	Konstantin Ananyev, David Hunt, Bruce Richardson, Byron Marohn,
	Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Reshma Pattan, Thomas Monjalon, Stephen Hemminger

On 04-Jul-19 8:43 AM, David Marchand wrote:
> On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov <anatoly.burakov@intel.com>
> wrote:
> 
>> diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h
>> b/lib/librte_eal/common/include/rte_eal_memconfig.h
>> index 58dcbb96d..1b615c892 100644
>> --- a/lib/librte_eal/common/include/rte_eal_memconfig.h
>> +++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
>> @@ -5,13 +5,12 @@
>>   #ifndef _RTE_EAL_MEMCONFIG_H_
>>   #define _RTE_EAL_MEMCONFIG_H_
>>
>> -#include <rte_config.h>
>> -#include <rte_tailq.h>
>> -#include <rte_memory.h>
>> -#include <rte_memzone.h>
>> -#include <rte_malloc_heap.h>
>> -#include <rte_rwlock.h>
>> -#include <rte_pause.h>
>> +/**
>> + * @file
>> + *
>> + * This API allows access to EAL shared memory configuration through an
>> API.
>> + */
>> +
>>   #include <rte_fbarray.h>
>>
>>   #ifdef __cplusplus
>> @@ -38,68 +37,6 @@ struct rte_memseg_list {
>>          struct rte_fbarray memseg_arr;
>>   };
>>
>>
> You left the rte_memseg_list definition here and the inclusion of
> rte_fbarray.h.
> Is this intentional?

Yes, it is intentional. I can move them to rte_memory, but they have to 
be externally visible.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 13/14] eal: unify internal config initialization
  2019-07-04  7:56       ` David Marchand
@ 2019-07-04 10:50         ` Burakov, Anatoly
  2019-07-04 10:54           ` David Marchand
  0 siblings, 1 reply; 117+ messages in thread
From: Burakov, Anatoly @ 2019-07-04 10:50 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Bruce Richardson, Thomas Monjalon, Stephen Hemminger

On 04-Jul-19 8:56 AM, David Marchand wrote:
> On Thu, Jul 4, 2019 at 9:50 AM David Marchand <david.marchand@redhat.com>
> wrote:
> 
>>
>>
>> On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov <anatoly.burakov@intel.com>
>> wrote:
>>
>>> Currently, each EAL will update internal/shared config in their
>>> own way at init, resulting in needless duplication of code and
>>> OS-dependent behavior. Move the functions to a common file and
>>> add missing FreeBSD steps.
>>>
>>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>>> ---
>>>   lib/librte_eal/common/eal_common_mcfg.c | 18 ++++++++++++++++++
>>>   lib/librte_eal/common/eal_memcfg.h      |  8 ++++++++
>>>   lib/librte_eal/freebsd/eal/eal.c        |  2 ++
>>>   lib/librte_eal/linux/eal/eal.c          | 22 ++--------------------
>>>   4 files changed, 30 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/lib/librte_eal/common/eal_common_mcfg.c
>>> b/lib/librte_eal/common/eal_common_mcfg.c
>>> index dc6665d6a..fe8d2b726 100644
>>> --- a/lib/librte_eal/common/eal_common_mcfg.c
>>> +++ b/lib/librte_eal/common/eal_common_mcfg.c
>>> @@ -31,6 +31,24 @@ eal_mcfg_wait_complete(void)
>>>                  rte_pause();
>>>   }
>>>
>>> +void
>>> +eal_mcfg_update_internal(void)
>>> +{
>>> +       struct rte_mem_config *mcfg =
>>> rte_eal_get_configuration()->mem_config;
>>> +
>>> +       internal_config.legacy_mem = mcfg->legacy_mem;
>>> +       internal_config.single_file_segments = mcfg->single_file_segments;
>>> +}
>>> +
>>> +void
>>> +eal_mcfg_update_from_internal(void)
>>> +{
>>> +       struct rte_mem_config *mcfg =
>>> rte_eal_get_configuration()->mem_config;
>>> +
>>> +       mcfg->legacy_mem = internal_config.legacy_mem;
>>> +       mcfg->single_file_segments = internal_config.single_file_segments;
>>> +}
>>> +
>>>   void
>>>   rte_mcfg_mem_read_lock(void)
>>>   {
>>> diff --git a/lib/librte_eal/common/eal_memcfg.h
>>> b/lib/librte_eal/common/eal_memcfg.h
>>> index a2434417e..d02ac1621 100644
>>> --- a/lib/librte_eal/common/eal_memcfg.h
>>> +++ b/lib/librte_eal/common/eal_memcfg.h
>>> @@ -68,6 +68,14 @@ struct rte_mem_config {
>>>          uint8_t dma_maskbits;
>>>   };
>>>
>>> +/* update internal config from shared mem config */
>>> +void
>>> +eal_mcfg_update_internal(void);
>>> +
>>> +/* update shared mem config from internal config */
>>> +void
>>> +eal_mcfg_update_from_internal(void);
>>> +
>>>   /* wait until primary process initialization is complete */
>>>   void
>>>   eal_mcfg_wait_complete(void);
>>> diff --git a/lib/librte_eal/freebsd/eal/eal.c
>>> b/lib/librte_eal/freebsd/eal/eal.c
>>> index 13e230fc8..6bfe203fd 100644
>>> --- a/lib/librte_eal/freebsd/eal/eal.c
>>> +++ b/lib/librte_eal/freebsd/eal/eal.c
>>> @@ -379,6 +379,7 @@ rte_config_init(void)
>>>          case RTE_PROC_PRIMARY:
>>>                  if (rte_eal_config_create() < 0)
>>>                          return -1;
>>> +               eal_mcfg_update_internal();
>>>                  break;
>>>          case RTE_PROC_SECONDARY:
>>>                  if (rte_eal_config_attach() < 0)
>>> @@ -386,6 +387,7 @@ rte_config_init(void)
>>>                  eal_mcfg_wait_complete();
>>>                  if (rte_eal_config_reattach() < 0)
>>>                          return -1;
>>> +               eal_mcfg_update_from_internal();
>>>                  break;
>>>          case RTE_PROC_AUTO:
>>>          case RTE_PROC_INVALID:
>>>
>>
>>
>> Hum, you swapped eal_mcfg_update_internal and
>> eal_mcfg_update_from_internal.
>> The names are a bit ambiguous, and I wonder if we really need those
>> separate helpers.
>>
> 
> Replying to myself... at least those helpers try to do something
> explicitly: synchronising the local copy of the configuration with the
> shared mem config.
> Keeping them separate documents this step.
> 
> Anyway, your choice, but you must fix freebsd :-)
> 

Sorry, i don't follow - what needs to be fixed in FreeBSD?

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 09/14] eal: hide shared memory config
  2019-07-04 10:47       ` Burakov, Anatoly
@ 2019-07-04 10:52         ` David Marchand
  0 siblings, 0 replies; 117+ messages in thread
From: David Marchand @ 2019-07-04 10:52 UTC (permalink / raw)
  To: Burakov, Anatoly
  Cc: dev, Neil Horman, John McNamara, Marko Kovacevic,
	Konstantin Ananyev, David Hunt, Bruce Richardson, Byron Marohn,
	Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Reshma Pattan, Thomas Monjalon, Stephen Hemminger

On Thu, Jul 4, 2019 at 12:47 PM Burakov, Anatoly <anatoly.burakov@intel.com>
wrote:

> On 04-Jul-19 8:43 AM, David Marchand wrote:
> > On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov <
> anatoly.burakov@intel.com>
> > wrote:
> >
> >> diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h
> >> b/lib/librte_eal/common/include/rte_eal_memconfig.h
> >> index 58dcbb96d..1b615c892 100644
> >> --- a/lib/librte_eal/common/include/rte_eal_memconfig.h
> >> +++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
> >> @@ -5,13 +5,12 @@
> >>   #ifndef _RTE_EAL_MEMCONFIG_H_
> >>   #define _RTE_EAL_MEMCONFIG_H_
> >>
> >> -#include <rte_config.h>
> >> -#include <rte_tailq.h>
> >> -#include <rte_memory.h>
> >> -#include <rte_memzone.h>
> >> -#include <rte_malloc_heap.h>
> >> -#include <rte_rwlock.h>
> >> -#include <rte_pause.h>
> >> +/**
> >> + * @file
> >> + *
> >> + * This API allows access to EAL shared memory configuration through an
> >> API.
> >> + */
> >> +
> >>   #include <rte_fbarray.h>
> >>
> >>   #ifdef __cplusplus
> >> @@ -38,68 +37,6 @@ struct rte_memseg_list {
> >>          struct rte_fbarray memseg_arr;
> >>   };
> >>
> >>
> > You left the rte_memseg_list definition here and the inclusion of
> > rte_fbarray.h.
> > Is this intentional?
>
> Yes, it is intentional. I can move them to rte_memory, but they have to
> be externally visible.
>

It makes more sense in rte_memory.h yes.
But I tried to do this, and hit compilation issues with conflicts on bool
type in base drivers...

Anyway, this could be a cleanup later.


-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 13/14] eal: unify internal config initialization
  2019-07-04 10:50         ` Burakov, Anatoly
@ 2019-07-04 10:54           ` David Marchand
  2019-07-04 11:26             ` Burakov, Anatoly
  0 siblings, 1 reply; 117+ messages in thread
From: David Marchand @ 2019-07-04 10:54 UTC (permalink / raw)
  To: Burakov, Anatoly
  Cc: dev, Bruce Richardson, Thomas Monjalon, Stephen Hemminger

On Thu, Jul 4, 2019 at 12:50 PM Burakov, Anatoly <anatoly.burakov@intel.com>
wrote:

> On 04-Jul-19 8:56 AM, David Marchand wrote:
> > On Thu, Jul 4, 2019 at 9:50 AM David Marchand <david.marchand@redhat.com
> >
> > wrote:
> >
> >>
> >>
> >> On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov <
> anatoly.burakov@intel.com>
> >> wrote:
> >>
> >>> Currently, each EAL will update internal/shared config in their
> >>> own way at init, resulting in needless duplication of code and
> >>> OS-dependent behavior. Move the functions to a common file and
> >>> add missing FreeBSD steps.
> >>>
> >>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> >>> ---
> >>>   lib/librte_eal/common/eal_common_mcfg.c | 18 ++++++++++++++++++
> >>>   lib/librte_eal/common/eal_memcfg.h      |  8 ++++++++
> >>>   lib/librte_eal/freebsd/eal/eal.c        |  2 ++
> >>>   lib/librte_eal/linux/eal/eal.c          | 22 ++--------------------
> >>>   4 files changed, 30 insertions(+), 20 deletions(-)
> >>>
> >>> diff --git a/lib/librte_eal/common/eal_common_mcfg.c
> >>> b/lib/librte_eal/common/eal_common_mcfg.c
> >>> index dc6665d6a..fe8d2b726 100644
> >>> --- a/lib/librte_eal/common/eal_common_mcfg.c
> >>> +++ b/lib/librte_eal/common/eal_common_mcfg.c
> >>> @@ -31,6 +31,24 @@ eal_mcfg_wait_complete(void)
> >>>                  rte_pause();
> >>>   }
> >>>
> >>> +void
> >>> +eal_mcfg_update_internal(void)
> >>> +{
> >>> +       struct rte_mem_config *mcfg =
> >>> rte_eal_get_configuration()->mem_config;
> >>> +
> >>> +       internal_config.legacy_mem = mcfg->legacy_mem;
> >>> +       internal_config.single_file_segments =
> mcfg->single_file_segments;
> >>> +}
> >>> +
> >>> +void
> >>> +eal_mcfg_update_from_internal(void)
> >>> +{
> >>> +       struct rte_mem_config *mcfg =
> >>> rte_eal_get_configuration()->mem_config;
> >>> +
> >>> +       mcfg->legacy_mem = internal_config.legacy_mem;
> >>> +       mcfg->single_file_segments =
> internal_config.single_file_segments;
> >>> +}
> >>> +
> >>>   void
> >>>   rte_mcfg_mem_read_lock(void)
> >>>   {
> >>> diff --git a/lib/librte_eal/common/eal_memcfg.h
> >>> b/lib/librte_eal/common/eal_memcfg.h
> >>> index a2434417e..d02ac1621 100644
> >>> --- a/lib/librte_eal/common/eal_memcfg.h
> >>> +++ b/lib/librte_eal/common/eal_memcfg.h
> >>> @@ -68,6 +68,14 @@ struct rte_mem_config {
> >>>          uint8_t dma_maskbits;
> >>>   };
> >>>
> >>> +/* update internal config from shared mem config */
> >>> +void
> >>> +eal_mcfg_update_internal(void);
> >>> +
> >>> +/* update shared mem config from internal config */
> >>> +void
> >>> +eal_mcfg_update_from_internal(void);
> >>> +
> >>>   /* wait until primary process initialization is complete */
> >>>   void
> >>>   eal_mcfg_wait_complete(void);
> >>> diff --git a/lib/librte_eal/freebsd/eal/eal.c
> >>> b/lib/librte_eal/freebsd/eal/eal.c
> >>> index 13e230fc8..6bfe203fd 100644
> >>> --- a/lib/librte_eal/freebsd/eal/eal.c
> >>> +++ b/lib/librte_eal/freebsd/eal/eal.c
> >>> @@ -379,6 +379,7 @@ rte_config_init(void)
> >>>          case RTE_PROC_PRIMARY:
> >>>                  if (rte_eal_config_create() < 0)
> >>>                          return -1;
> >>> +               eal_mcfg_update_internal();
> >>>                  break;
> >>>          case RTE_PROC_SECONDARY:
> >>>                  if (rte_eal_config_attach() < 0)
> >>> @@ -386,6 +387,7 @@ rte_config_init(void)
> >>>                  eal_mcfg_wait_complete();
> >>>                  if (rte_eal_config_reattach() < 0)
> >>>                          return -1;
> >>> +               eal_mcfg_update_from_internal();
> >>>                  break;
> >>>          case RTE_PROC_AUTO:
> >>>          case RTE_PROC_INVALID:
> >>>
> >>
> >>
> >> Hum, you swapped eal_mcfg_update_internal and
> >> eal_mcfg_update_from_internal.
> >> The names are a bit ambiguous, and I wonder if we really need those
> >> separate helpers.
> >>
> >
> > Replying to myself... at least those helpers try to do something
> > explicitly: synchronising the local copy of the configuration with the
> > shared mem config.
> > Keeping them separate documents this step.
> >
> > Anyway, your choice, but you must fix freebsd :-)
> >
>
> Sorry, i don't follow - what needs to be fixed in FreeBSD?
>

eal_mcfg_update_from_internal() must be called in primary process.
eal_mcfg_update_internal() must be called in secondary processes.


-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 13/14] eal: unify internal config initialization
  2019-07-04 10:54           ` David Marchand
@ 2019-07-04 11:26             ` Burakov, Anatoly
  0 siblings, 0 replies; 117+ messages in thread
From: Burakov, Anatoly @ 2019-07-04 11:26 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Bruce Richardson, Thomas Monjalon, Stephen Hemminger

On 04-Jul-19 11:54 AM, David Marchand wrote:
> 
> 
> On Thu, Jul 4, 2019 at 12:50 PM Burakov, Anatoly 
> <anatoly.burakov@intel.com <mailto:anatoly.burakov@intel.com>> wrote:
> 
>     On 04-Jul-19 8:56 AM, David Marchand wrote:
>      > On Thu, Jul 4, 2019 at 9:50 AM David Marchand
>     <david.marchand@redhat.com <mailto:david.marchand@redhat.com>>
>      > wrote:
>      >
>      >>
>      >>
>      >> On Thu, Jun 27, 2019 at 1:39 PM Anatoly Burakov
>     <anatoly.burakov@intel.com <mailto:anatoly.burakov@intel.com>>
>      >> wrote:
>      >>
>      >>> Currently, each EAL will update internal/shared config in their
>      >>> own way at init, resulting in needless duplication of code and
>      >>> OS-dependent behavior. Move the functions to a common file and
>      >>> add missing FreeBSD steps.
>      >>>
>      >>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com
>     <mailto:anatoly.burakov@intel.com>>
>      >>> ---
>      >>>   lib/librte_eal/common/eal_common_mcfg.c | 18 ++++++++++++++++++
>      >>>   lib/librte_eal/common/eal_memcfg.h      |  8 ++++++++
>      >>>   lib/librte_eal/freebsd/eal/eal.c        |  2 ++
>      >>>   lib/librte_eal/linux/eal/eal.c          | 22
>     ++--------------------
>      >>>   4 files changed, 30 insertions(+), 20 deletions(-)
>      >>>
>      >>> diff --git a/lib/librte_eal/common/eal_common_mcfg.c
>      >>> b/lib/librte_eal/common/eal_common_mcfg.c
>      >>> index dc6665d6a..fe8d2b726 100644
>      >>> --- a/lib/librte_eal/common/eal_common_mcfg.c
>      >>> +++ b/lib/librte_eal/common/eal_common_mcfg.c
>      >>> @@ -31,6 +31,24 @@ eal_mcfg_wait_complete(void)
>      >>>                  rte_pause();
>      >>>   }
>      >>>
>      >>> +void
>      >>> +eal_mcfg_update_internal(void)
>      >>> +{
>      >>> +       struct rte_mem_config *mcfg =
>      >>> rte_eal_get_configuration()->mem_config;
>      >>> +
>      >>> +       internal_config.legacy_mem = mcfg->legacy_mem;
>      >>> +       internal_config.single_file_segments =
>     mcfg->single_file_segments;
>      >>> +}
>      >>> +
>      >>> +void
>      >>> +eal_mcfg_update_from_internal(void)
>      >>> +{
>      >>> +       struct rte_mem_config *mcfg =
>      >>> rte_eal_get_configuration()->mem_config;
>      >>> +
>      >>> +       mcfg->legacy_mem = internal_config.legacy_mem;
>      >>> +       mcfg->single_file_segments =
>     internal_config.single_file_segments;
>      >>> +}
>      >>> +
>      >>>   void
>      >>>   rte_mcfg_mem_read_lock(void)
>      >>>   {
>      >>> diff --git a/lib/librte_eal/common/eal_memcfg.h
>      >>> b/lib/librte_eal/common/eal_memcfg.h
>      >>> index a2434417e..d02ac1621 100644
>      >>> --- a/lib/librte_eal/common/eal_memcfg.h
>      >>> +++ b/lib/librte_eal/common/eal_memcfg.h
>      >>> @@ -68,6 +68,14 @@ struct rte_mem_config {
>      >>>          uint8_t dma_maskbits;
>      >>>   };
>      >>>
>      >>> +/* update internal config from shared mem config */
>      >>> +void
>      >>> +eal_mcfg_update_internal(void);
>      >>> +
>      >>> +/* update shared mem config from internal config */
>      >>> +void
>      >>> +eal_mcfg_update_from_internal(void);
>      >>> +
>      >>>   /* wait until primary process initialization is complete */
>      >>>   void
>      >>>   eal_mcfg_wait_complete(void);
>      >>> diff --git a/lib/librte_eal/freebsd/eal/eal.c
>      >>> b/lib/librte_eal/freebsd/eal/eal.c
>      >>> index 13e230fc8..6bfe203fd 100644
>      >>> --- a/lib/librte_eal/freebsd/eal/eal.c
>      >>> +++ b/lib/librte_eal/freebsd/eal/eal.c
>      >>> @@ -379,6 +379,7 @@ rte_config_init(void)
>      >>>          case RTE_PROC_PRIMARY:
>      >>>                  if (rte_eal_config_create() < 0)
>      >>>                          return -1;
>      >>> +               eal_mcfg_update_internal();
>      >>>                  break;
>      >>>          case RTE_PROC_SECONDARY:
>      >>>                  if (rte_eal_config_attach() < 0)
>      >>> @@ -386,6 +387,7 @@ rte_config_init(void)
>      >>>                  eal_mcfg_wait_complete();
>      >>>                  if (rte_eal_config_reattach() < 0)
>      >>>                          return -1;
>      >>> +               eal_mcfg_update_from_internal();
>      >>>                  break;
>      >>>          case RTE_PROC_AUTO:
>      >>>          case RTE_PROC_INVALID:
>      >>>
>      >>
>      >>
>      >> Hum, you swapped eal_mcfg_update_internal and
>      >> eal_mcfg_update_from_internal.
>      >> The names are a bit ambiguous, and I wonder if we really need those
>      >> separate helpers.
>      >>
>      >
>      > Replying to myself... at least those helpers try to do something
>      > explicitly: synchronising the local copy of the configuration
>     with the
>      > shared mem config.
>      > Keeping them separate documents this step.
>      >
>      > Anyway, your choice, but you must fix freebsd :-)
>      >
> 
>     Sorry, i don't follow - what needs to be fixed in FreeBSD?
> 
> 
> eal_mcfg_update_from_internal() must be called in primary process.
> eal_mcfg_update_internal() must be called in secondary processes.
> 

Oh, right, good catch, thanks!

> 
> -- 
> David Marchand


-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 09/14] eal: hide shared memory config
  2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 09/14] eal: hide shared memory config Anatoly Burakov
  2019-07-04  7:43     ` David Marchand
@ 2019-07-04 19:51     ` Thomas Monjalon
  1 sibling, 0 replies; 117+ messages in thread
From: Thomas Monjalon @ 2019-07-04 19:51 UTC (permalink / raw)
  To: Anatoly Burakov
  Cc: dev, Neil Horman, John McNamara, Marko Kovacevic,
	Konstantin Ananyev, David Hunt, Bruce Richardson, Byron Marohn,
	Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Reshma Pattan, david.marchand, stephen

27/06/2019 13:39, Anatoly Burakov:
> +/**
> + * the structure for the memory configuration for the RTE.
> + * Used by the rte_config structure. It is separated out, as for multi-process
> + * support, the memory details should be shared across instances
> + */
> +struct rte_mem_config {
> +	volatile uint32_t magic;   /**< Magic number - Sanity check. */
> +
> +	/* memory topology */
> +	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
> +	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
> +
> +	/**
> +	 * current lock nest order
> +	 *  - qlock->mlock (ring/hash/lpm)
> +	 *  - mplock->qlock->mlock (mempool)
> +	 * Notice:
> +	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
> +	 */
> +	rte_rwlock_t mlock;   /**< only used by memzone LIB for thread-safe. */
> +	rte_rwlock_t qlock;   /**< used for tailq operation for thread safe. */
> +	rte_rwlock_t mplock;  /**< only used by mempool LIB for thread-safe. */
> +
> +	rte_rwlock_t memory_hotplug_lock;
> +	/**< indicates whether memory hotplug request is in progress. */
> +
> +	/* memory segments and zones */
> +	struct rte_fbarray memzones; /**< Memzone descriptors. */
> +
> +	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
> +	/**< list of dynamic arrays holding memsegs */
> +
> +	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ];
> +	/**< Tailqs for objects */
> +
> +	/* Heaps of Malloc */
> +	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
> +
> +	/* next socket ID for external malloc heap */
> +	int next_socket_id;
> +
> +	/* address of mem_config in primary process. used to map shared config
> +	 * into exact same address the primary process maps it.
> +	 */
> +	uint64_t mem_cfg_addr;
> +
> +	/* legacy mem and single file segments options are shared */
> +	uint32_t legacy_mem;
> +	uint32_t single_file_segments;
> +
> +	/* keeps the more restricted dma mask */
> +	uint8_t dma_maskbits;
> +} __attribute__((packed));

While moving it, you could take the opportunity to do some
small cleanups of the comments, like removing "for the RTE",
or adding some uppercases and dots, etc.



^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v3 00/14] Make shared memory config non-public
  2019-07-04  8:09       ` David Marchand
@ 2019-07-04 19:52         ` Thomas Monjalon
  0 siblings, 0 replies; 117+ messages in thread
From: Thomas Monjalon @ 2019-07-04 19:52 UTC (permalink / raw)
  To: David Marchand, Anatoly Burakov; +Cc: dev, Stephen Hemminger

04/07/2019 10:09, David Marchand:
> I just want to state two approaches to merge these changes:
> - the first one would be to split this series in two
>   - take the first part of this series now, but mark the new API
> "experimental"
>   - postpone the merge to 19.11 of the second part, which starts at the
> hiding rte_mem_config patch
> - the second one is taking these changes in one go
> 
> The second one is the quicker and the more straightforward but it leaves
> the risk of having missed something and we must break the ABI again in
> 19.11.
> The risk is quite low, given the changes.
> 
> 
> Thomas, comments?

OK to merge it in one go.
Please, can we merge it tomorrow?





^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v4 0/8] Make shared memory config non-public
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
  2019-06-27 15:36     ` Stephen Hemminger
  2019-07-03  9:38     ` David Marchand
@ 2019-07-05 13:10     ` Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 0/9] " Anatoly Burakov
                         ` (9 more replies)
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 1/8] eal: add API to lock/unlock memory hotplug Anatoly Burakov
                       ` (7 subsequent siblings)
  10 siblings, 10 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 13:10 UTC (permalink / raw)
  To: dev; +Cc: thomas, david.marchand, stephen

This patchset removes the shared memory config from public
API, and replaces all usages of said config with new API
calls.

A lot of the patchset is a search-and-replace job and should
be pretty easy to review. The rest are pretty trivial EAL
changes.

v4:
- Rebase on top of latest master
- Squashed more commits
- Added some cleanups
  - Comment cleanup in mem config
  - Moved memseg list struct to rte_memory
- Fixed init in FreeBSD when storing data in config

v3:
- Rebase on top of latest master

v2:
- Collapsed all changes into fewer patches
- Addressed review comments
- Created a new file to store the code
- Changed namespace to "rte_mcfg_"
- Added some unification around config init
- Removed "packed" attribute from mem config
- Removed unnecessary inlining
- Added a check to explicitly forbid running multiprocess
  applications that differ in their DPDK versions

Anatoly Burakov (8):
  eal: add API to lock/unlock memory hotplug
  eal: add EAL tailq list lock/unlock API
  eal: add new API to lock/unlock mempool list
  eal: hide shared memory config
  eal: remove packed attribute from mcfg structure
  eal: uninline wait for mcfg complete function
  eal: unify and move mcfg complete function
  eal: unify internal config initialization

 app/test/test_fbarray.c                       |   1 +
 app/test/test_memzone.c                       |   1 +
 app/test/test_tailq.c                         |   1 +
 doc/guides/rel_notes/deprecation.rst          |   3 -
 doc/guides/rel_notes/release_19_08.rst        |   8 +-
 drivers/bus/fslmc/fslmc_vfio.c                |   8 +-
 drivers/bus/pci/linux/pci_vfio.c              |   1 +
 drivers/net/mlx4/mlx4_mr.c                    |  11 +-
 drivers/net/mlx5/mlx5_mr.c                    |  11 +-
 .../net/virtio/virtio_user/virtio_user_dev.c  |   7 +-
 lib/librte_acl/rte_acl.c                      |  20 +--
 lib/librte_distributor/rte_distributor.c      |   5 +-
 lib/librte_distributor/rte_distributor_v20.c  |   5 +-
 lib/librte_eal/common/eal_common_mcfg.c       | 134 +++++++++++++++++
 lib/librte_eal/common/eal_common_memory.c     |  44 +++---
 lib/librte_eal/common/eal_common_memzone.c    |   1 +
 lib/librte_eal/common/eal_common_tailqs.c     |   5 +-
 lib/librte_eal/common/eal_memcfg.h            |  88 ++++++++++++
 lib/librte_eal/common/include/rte_eal.h       |  10 --
 .../common/include/rte_eal_memconfig.h        | 135 ++++++++----------
 lib/librte_eal/common/include/rte_fbarray.h   |   1 -
 lib/librte_eal/common/include/rte_memory.h    |  24 +++-
 lib/librte_eal/common/malloc_heap.c           |  16 +--
 lib/librte_eal/common/malloc_mp.c             |   1 +
 lib/librte_eal/common/meson.build             |   1 +
 lib/librte_eal/common/rte_malloc.c            |  33 ++---
 lib/librte_eal/freebsd/eal/Makefile           |   3 +-
 lib/librte_eal/freebsd/eal/eal.c              |  17 +--
 lib/librte_eal/freebsd/eal/eal_memory.c       |   1 +
 lib/librte_eal/linux/eal/Makefile             |   3 +-
 lib/librte_eal/linux/eal/eal.c                |  37 +----
 lib/librte_eal/linux/eal/eal_memalloc.c       |   1 +
 lib/librte_eal/linux/eal/eal_memory.c         |   1 +
 lib/librte_eal/linux/eal/eal_vfio.c           |  17 +--
 lib/librte_eal/meson.build                    |   2 +-
 lib/librte_eal/rte_eal_version.map            |  12 ++
 lib/librte_efd/rte_efd.c                      |  15 +-
 lib/librte_eventdev/rte_event_ring.c          |  16 +--
 lib/librte_hash/rte_cuckoo_hash.c             |  17 +--
 lib/librte_hash/rte_fbk_hash.c                |  15 +-
 lib/librte_kni/rte_kni.c                      |  16 +--
 lib/librte_lpm/rte_lpm.c                      |  25 ++--
 lib/librte_lpm/rte_lpm6.c                     |  15 +-
 lib/librte_member/rte_member.c                |  17 +--
 lib/librte_mempool/rte_mempool.c              |  27 ++--
 lib/librte_rcu/rte_rcu_qsbr.h                 |   1 +
 lib/librte_reorder/rte_reorder.c              |  15 +-
 lib/librte_ring/rte_ring.c                    |  19 +--
 lib/librte_stack/rte_stack.c                  |  18 +--
 49 files changed, 546 insertions(+), 339 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_mcfg.c
 create mode 100644 lib/librte_eal/common/eal_memcfg.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v4 1/8] eal: add API to lock/unlock memory hotplug
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
                       ` (2 preceding siblings ...)
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
@ 2019-07-05 13:10     ` Anatoly Burakov
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 2/8] eal: add EAL tailq list lock/unlock API Anatoly Burakov
                       ` (6 subsequent siblings)
  10 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 13:10 UTC (permalink / raw)
  To: dev
  Cc: Hemant Agrawal, Shreyansh Jain, Matan Azrad, Shahaf Shuler,
	Yongseok Koh, Maxime Coquelin, Tiwei Bie, Zhihong Wang,
	Bruce Richardson, thomas, david.marchand, stephen

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_*, and search-and-replace all
usages of the locks with the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/bus/fslmc/fslmc_vfio.c                |  8 ++--
 drivers/net/mlx4/mlx4_mr.c                    | 11 +++--
 drivers/net/mlx5/mlx5_mr.c                    | 11 +++--
 .../net/virtio/virtio_user/virtio_user_dev.c  |  7 ++-
 lib/librte_eal/common/eal_common_mcfg.c       | 34 +++++++++++++++
 lib/librte_eal/common/eal_common_memory.c     | 43 ++++++++-----------
 .../common/include/rte_eal_memconfig.h        | 24 +++++++++++
 lib/librte_eal/common/malloc_heap.c           | 14 +++---
 lib/librte_eal/common/meson.build             |  1 +
 lib/librte_eal/common/rte_malloc.c            | 32 ++++++--------
 lib/librte_eal/freebsd/eal/Makefile           |  1 +
 lib/librte_eal/linux/eal/Makefile             |  1 +
 lib/librte_eal/linux/eal/eal_vfio.c           | 16 +++----
 lib/librte_eal/rte_eal_version.map            |  4 ++
 14 files changed, 125 insertions(+), 82 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_mcfg.c

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 1aae56fa9..44e4fa6e2 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -347,14 +347,12 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,
 int rte_fslmc_vfio_dmamap(void)
 {
 	int i = 0, ret;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 
 	/* Lock before parsing and registering callback to memory subsystem */
-	rte_rwlock_read_lock(mem_lock);
+	rte_mcfg_mem_read_lock();
 
 	if (rte_memseg_walk(fslmc_dmamap_seg, &i) < 0) {
-		rte_rwlock_read_unlock(mem_lock);
+		rte_mcfg_mem_read_unlock();
 		return -1;
 	}
 
@@ -378,7 +376,7 @@ int rte_fslmc_vfio_dmamap(void)
 	/* Existing segments have been mapped and memory callback for hotplug
 	 * has been installed.
 	 */
-	rte_rwlock_read_unlock(mem_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return 0;
 }
diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
index 48d458ad4..80827ce75 100644
--- a/drivers/net/mlx4/mlx4_mr.c
+++ b/drivers/net/mlx4/mlx4_mr.c
@@ -593,7 +593,6 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		       uintptr_t addr)
 {
 	struct mlx4_priv *priv = dev->data->dev_private;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	const struct rte_memseg_list *msl;
 	const struct rte_memseg *ms;
 	struct mlx4_mr *mr = NULL;
@@ -696,7 +695,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	 * just single page. If not, go on with the big chunk atomically from
 	 * here.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	data_re = data;
 	if (len > msl->page_sz &&
 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
@@ -714,7 +713,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		 */
 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
 		data.end = data.start + msl->page_sz;
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		mr_free(mr);
 		goto alloc_resources;
 	}
@@ -734,7 +733,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		DEBUG("port %u found MR for %p on final lookup, abort",
 		      dev->data->port_id, (void *)addr);
 		rte_rwlock_write_unlock(&priv->mr.rwlock);
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		/*
 		 * Must be unlocked before calling rte_free() because
 		 * mlx4_mr_mem_event_free_cb() can be called inside.
@@ -802,12 +801,12 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	/* Lookup can't fail. */
 	assert(entry->lkey != UINT32_MAX);
 	rte_rwlock_write_unlock(&priv->mr.rwlock);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return entry->lkey;
 err_mrlock:
 	rte_rwlock_write_unlock(&priv->mr.rwlock);
 err_memlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 err_nolock:
 	/*
 	 * In case of error, as this can be called in a datapath, a warning
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 66e8e874e..872d0591e 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -580,7 +580,6 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_ibv_shared *sh = priv->sh;
 	struct mlx5_dev_config *config = &priv->config;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	const struct rte_memseg_list *msl;
 	const struct rte_memseg *ms;
 	struct mlx5_mr *mr = NULL;
@@ -684,7 +683,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	 * just single page. If not, go on with the big chunk atomically from
 	 * here.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	data_re = data;
 	if (len > msl->page_sz &&
 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
@@ -702,7 +701,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 		 */
 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
 		data.end = data.start + msl->page_sz;
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		mr_free(mr);
 		goto alloc_resources;
 	}
@@ -722,7 +721,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 		DEBUG("port %u found MR for %p on final lookup, abort",
 		      dev->data->port_id, (void *)addr);
 		rte_rwlock_write_unlock(&sh->mr.rwlock);
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		/*
 		 * Must be unlocked before calling rte_free() because
 		 * mlx5_mr_mem_event_free_cb() can be called inside.
@@ -790,12 +789,12 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	/* Lookup can't fail. */
 	assert(entry->lkey != UINT32_MAX);
 	rte_rwlock_write_unlock(&sh->mr.rwlock);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return entry->lkey;
 err_mrlock:
 	rte_rwlock_write_unlock(&sh->mr.rwlock);
 err_memlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 err_nolock:
 	/*
 	 * In case of error, as this can be called in a datapath, a warning
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index e743695e4..c3ab9a21d 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -125,7 +125,6 @@ is_vhost_user_by_type(const char *path)
 int
 virtio_user_start_device(struct virtio_user_dev *dev)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	uint64_t features;
 	int ret;
 
@@ -142,7 +141,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 	 * replaced when we get proper supports from the
 	 * memory subsystem in the future.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	pthread_mutex_lock(&dev->mutex);
 
 	if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0)
@@ -180,12 +179,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 
 	dev->started = true;
 	pthread_mutex_unlock(&dev->mutex);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return 0;
 error:
 	pthread_mutex_unlock(&dev->mutex);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	/* TODO: free resource here or caller to check */
 	return -1;
 }
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 <rte_config.h>
+#include <rte_eal_memconfig.h>
+
+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/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 858d56382..fe22b139b 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -596,13 +596,12 @@ rte_memseg_contig_walk_thread_unsafe(rte_memseg_contig_walk_t func, void *arg)
 int
 rte_memseg_contig_walk(rte_memseg_contig_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_contig_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -638,13 +637,12 @@ rte_memseg_walk_thread_unsafe(rte_memseg_walk_t func, void *arg)
 int
 rte_memseg_walk(rte_memseg_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -671,13 +669,12 @@ rte_memseg_list_walk_thread_unsafe(rte_memseg_list_walk_t func, void *arg)
 int
 rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_list_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -727,12 +724,11 @@ rte_memseg_get_fd_thread_unsafe(const struct rte_memseg *ms)
 int
 rte_memseg_get_fd(const struct rte_memseg *ms)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_get_fd_thread_unsafe(ms);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -783,12 +779,11 @@ rte_memseg_get_fd_offset_thread_unsafe(const struct rte_memseg *ms,
 int
 rte_memseg_get_fd_offset(const struct rte_memseg *ms, size_t *offset)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_get_fd_offset_thread_unsafe(ms, offset);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -809,7 +804,7 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* make sure the segment doesn't already exist */
 	if (malloc_heap_find_external_seg(va_addr, len) != NULL) {
@@ -838,14 +833,13 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
 	/* memseg list successfully created - increment next socket ID */
 	mcfg->next_socket_id++;
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
 int
 rte_extmem_unregister(void *va_addr, size_t len)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct rte_memseg_list *msl;
 	int ret = 0;
 
@@ -853,7 +847,7 @@ rte_extmem_unregister(void *va_addr, size_t len)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our segment */
 	msl = malloc_heap_find_external_seg(va_addr, len);
@@ -865,14 +859,13 @@ rte_extmem_unregister(void *va_addr, size_t len)
 
 	ret = malloc_heap_destroy_external_seg(msl);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
 static int
 sync_memory(void *va_addr, size_t len, bool attach)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct rte_memseg_list *msl;
 	int ret = 0;
 
@@ -880,7 +873,7 @@ sync_memory(void *va_addr, size_t len, bool attach)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our segment */
 	msl = malloc_heap_find_external_seg(va_addr, len);
@@ -895,7 +888,7 @@ sync_memory(void *va_addr, size_t len, bool attach)
 		ret = rte_fbarray_detach(&msl->memseg_arr);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
@@ -923,7 +916,7 @@ rte_eal_memory_init(void)
 		return -1;
 
 	/* lock mem hotplug here, to prevent races while we init */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 
 	if (rte_eal_memseg_init() < 0)
 		goto fail;
@@ -942,6 +935,6 @@ rte_eal_memory_init(void)
 
 	return 0;
 fail:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return -1;
 }
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/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index f9235932e..f1d31de0d 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -485,10 +485,9 @@ try_expand_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,
 		int socket, unsigned int flags, size_t align, size_t bound,
 		bool contig)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		ret = try_expand_heap_primary(heap, pg_sz, elt_size, socket,
@@ -498,7 +497,7 @@ try_expand_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,
 				flags, align, bound, contig);
 	}
 
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
@@ -821,7 +820,6 @@ malloc_heap_free_pages(void *aligned_start, size_t aligned_len)
 int
 malloc_heap_free(struct malloc_elem *elem)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap;
 	void *start, *aligned_start, *end, *aligned_end;
 	size_t len, aligned_len, page_sz;
@@ -935,7 +933,7 @@ malloc_heap_free(struct malloc_elem *elem)
 
 	/* now we can finally free us some pages */
 
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/*
 	 * we allow secondary processes to clear the heap of this allocated
@@ -990,7 +988,7 @@ malloc_heap_free(struct malloc_elem *elem)
 	RTE_LOG(DEBUG, EAL, "Heap on socket %d was shrunk by %zdMB\n",
 		msl->socket_id, aligned_len >> 20ULL);
 
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 free_unlock:
 	rte_spinlock_unlock(&(heap->lock));
 	return ret;
@@ -1344,7 +1342,7 @@ rte_eal_malloc_heap_init(void)
 
 	if (register_mp_requests()) {
 		RTE_LOG(ERR, EAL, "Couldn't register malloc multiprocess actions\n");
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		return -1;
 	}
 
@@ -1352,7 +1350,7 @@ rte_eal_malloc_heap_init(void)
 	 * even come before primary itself is fully initialized, and secondaries
 	 * do not need to initialize the heap.
 	 */
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	/* secondary process does not need to initialize anything */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build
index bafd23207..58b433bc2 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/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index b119ebae3..2cad7beaa 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -223,7 +223,7 @@ rte_malloc_heap_get_socket(const char *name)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	for (idx = 0; idx < RTE_MAX_HEAPS; idx++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[idx];
 
@@ -239,7 +239,7 @@ rte_malloc_heap_get_socket(const char *name)
 		rte_errno = ENOENT;
 		ret = -1;
 	}
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -254,7 +254,7 @@ rte_malloc_heap_socket_is_external(int socket_id)
 	if (socket_id == SOCKET_ID_ANY)
 		return 0;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	for (idx = 0; idx < RTE_MAX_HEAPS; idx++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[idx];
 
@@ -264,7 +264,7 @@ rte_malloc_heap_socket_is_external(int socket_id)
 			break;
 		}
 	}
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -352,7 +352,6 @@ int
 rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 		rte_iova_t iova_addrs[], unsigned int n_pages, size_t page_sz)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	unsigned int n;
@@ -369,7 +368,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our heap */
 	heap = find_named_heap(heap_name);
@@ -398,7 +397,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 	rte_spinlock_unlock(&heap->lock);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -406,7 +405,6 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 int
 rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	int ret;
@@ -418,7 +416,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 	/* find our heap */
 	heap = find_named_heap(heap_name);
 	if (heap == NULL) {
@@ -448,7 +446,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 	ret = malloc_heap_destroy_external_seg(msl);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -456,7 +454,6 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 static int
 sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	int ret;
@@ -468,7 +465,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 
 	/* find our heap */
 	heap = find_named_heap(heap_name);
@@ -516,7 +513,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 		}
 	}
 unlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return ret;
 }
 
@@ -549,7 +546,7 @@ rte_malloc_heap_create(const char *heap_name)
 	/* check if there is space in the heap list, or if heap with this name
 	 * already exists.
 	 */
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	for (i = 0; i < RTE_MAX_HEAPS; i++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[i];
@@ -578,7 +575,7 @@ rte_malloc_heap_create(const char *heap_name)
 	/* we're sure that we can create a new heap, so do it */
 	ret = malloc_heap_create(heap, heap_name);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -586,7 +583,6 @@ rte_malloc_heap_create(const char *heap_name)
 int
 rte_malloc_heap_destroy(const char *heap_name)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	int ret;
 
@@ -597,7 +593,7 @@ rte_malloc_heap_destroy(const char *heap_name)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* start from non-socket heaps */
 	heap = find_named_heap(heap_name);
@@ -621,7 +617,7 @@ rte_malloc_heap_destroy(const char *heap_name)
 	if (ret < 0)
 		rte_spinlock_unlock(&heap->lock);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
diff --git a/lib/librte_eal/freebsd/eal/Makefile b/lib/librte_eal/freebsd/eal/Makefile
index ca616c480..eb921275e 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 729795a10..dfe8e9a49 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/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index feada64c0..96a03a657 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -635,8 +635,6 @@ int
 rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 		int *vfio_dev_fd, struct vfio_device_info *device_info)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 	struct vfio_group_status group_status = {
 			.argsz = sizeof(group_status)
 	};
@@ -739,7 +737,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 			/* lock memory hotplug before mapping and release it
 			 * after registering callback, to prevent races
 			 */
-			rte_rwlock_read_lock(mem_lock);
+			rte_mcfg_mem_read_lock();
 			if (vfio_cfg == default_vfio_cfg)
 				ret = t->dma_map_func(vfio_container_fd);
 			else
@@ -750,7 +748,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 					dev_addr, errno, strerror(errno));
 				close(vfio_group_fd);
 				rte_vfio_clear_group(vfio_group_fd);
-				rte_rwlock_read_unlock(mem_lock);
+				rte_mcfg_mem_read_unlock();
 				return -1;
 			}
 
@@ -781,7 +779,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 							map->len);
 					rte_spinlock_recursive_unlock(
 							&user_mem_maps->lock);
-					rte_rwlock_read_unlock(mem_lock);
+					rte_mcfg_mem_read_unlock();
 					return -1;
 				}
 			}
@@ -795,7 +793,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 			else
 				ret = 0;
 			/* unlock memory hotplug */
-			rte_rwlock_read_unlock(mem_lock);
+			rte_mcfg_mem_read_unlock();
 
 			if (ret && rte_errno != ENOTSUP) {
 				RTE_LOG(ERR, EAL, "Could not install memory event callback for VFIO\n");
@@ -862,8 +860,6 @@ int
 rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 		    int vfio_dev_fd)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 	struct vfio_group_status group_status = {
 			.argsz = sizeof(group_status)
 	};
@@ -876,7 +872,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 	 * VFIO device, because this might be the last device and we might need
 	 * to unregister the callback.
 	 */
-	rte_rwlock_read_lock(mem_lock);
+	rte_mcfg_mem_read_lock();
 
 	/* get group number */
 	ret = rte_vfio_get_group_num(sysfs_base, dev_addr, &iommu_group_num);
@@ -947,7 +943,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 	ret = 0;
 
 out:
-	rte_rwlock_read_unlock(mem_lock);
+	rte_mcfg_mem_read_unlock();
 	return ret;
 }
 
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index a53a29a35..754060dc9 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;
 	rte_rand;
 	rte_srand;
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v4 2/8] eal: add EAL tailq list lock/unlock API
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
                       ` (3 preceding siblings ...)
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 1/8] eal: add API to lock/unlock memory hotplug Anatoly Burakov
@ 2019-07-05 13:10     ` Anatoly Burakov
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 3/8] eal: add new API to lock/unlock mempool list Anatoly Burakov
                       ` (5 subsequent siblings)
  10 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 13:10 UTC (permalink / raw)
  To: dev
  Cc: Konstantin Ananyev, David Hunt, Byron Marohn,
	Pablo de Lara Guarch, Jerin Jacob, Yipeng Wang, Sameh Gobriel,
	Bruce Richardson, Ferruh Yigit, Vladimir Medvedkin, Olivier Matz,
	Andrew Rybchenko, Reshma Pattan, Gage Eads, thomas,
	david.marchand, stephen

Currently, locking/unlocking the TAILQ list requires direct
access to the shared memory config. Add an API to do the same,
and search-and-replace all usages.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_acl/rte_acl.c                      | 18 ++++++------
 lib/librte_distributor/rte_distributor.c      |  4 +--
 lib/librte_distributor/rte_distributor_v20.c  |  4 +--
 lib/librte_eal/common/eal_common_mcfg.c       | 28 +++++++++++++++++++
 lib/librte_eal/common/eal_common_tailqs.c     |  4 +--
 lib/librte_eal/common/include/rte_eal.h       |  5 ----
 .../common/include/rte_eal_memconfig.h        | 24 ++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  4 +++
 lib/librte_efd/rte_efd.c                      | 14 +++++-----
 lib/librte_eventdev/rte_event_ring.c          | 16 +++++------
 lib/librte_hash/rte_cuckoo_hash.c             | 16 +++++------
 lib/librte_hash/rte_fbk_hash.c                | 14 +++++-----
 lib/librte_kni/rte_kni.c                      | 16 +++++------
 lib/librte_lpm/rte_lpm.c                      | 24 ++++++++--------
 lib/librte_lpm/rte_lpm6.c                     | 14 +++++-----
 lib/librte_member/rte_member.c                | 16 +++++------
 lib/librte_mempool/rte_mempool.c              |  8 +++---
 lib/librte_reorder/rte_reorder.c              | 14 +++++-----
 lib/librte_ring/rte_ring.c                    | 18 ++++++------
 lib/librte_stack/rte_stack.c                  | 18 ++++++------
 20 files changed, 165 insertions(+), 114 deletions(-)

diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index fd5bd5e4e..7ff11d25f 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -156,13 +156,13 @@ rte_acl_find_existing(const char *name)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, acl_list, next) {
 		ctx = (struct rte_acl_ctx *) te->data;
 		if (strncmp(name, ctx->name, sizeof(ctx->name)) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -182,7 +182,7 @@ rte_acl_free(struct rte_acl_ctx *ctx)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, acl_list, next) {
@@ -190,13 +190,13 @@ rte_acl_free(struct rte_acl_ctx *ctx)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(acl_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(ctx->mem);
 	rte_free(ctx);
@@ -226,7 +226,7 @@ rte_acl_create(const struct rte_acl_param *param)
 	sz = sizeof(*ctx) + param->max_rule_num * param->rule_size;
 
 	/* get EAL TAILQ lock. */
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* if we already have one with that name */
 	TAILQ_FOREACH(te, acl_list, next) {
@@ -268,7 +268,7 @@ rte_acl_create(const struct rte_acl_param *param)
 	}
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return ctx;
 }
 
@@ -377,10 +377,10 @@ rte_acl_list_dump(void)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, acl_list, next) {
 		ctx = (struct rte_acl_ctx *) te->data;
 		rte_acl_dump(ctx);
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 }
diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 208abfb1d..9eb78b330 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -645,9 +645,9 @@ rte_distributor_create_v1705(const char *name,
 					  rte_dist_burst_list);
 
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(dist_burst_list, d, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return d;
 }
diff --git a/lib/librte_distributor/rte_distributor_v20.c b/lib/librte_distributor/rte_distributor_v20.c
index cd5940713..1fc03b971 100644
--- a/lib/librte_distributor/rte_distributor_v20.c
+++ b/lib/librte_distributor/rte_distributor_v20.c
@@ -392,9 +392,9 @@ rte_distributor_create_v20(const char *name,
 	distributor_list = RTE_TAILQ_CAST(rte_distributor_tailq.head,
 					  rte_distributor_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(distributor_list, d, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return d;
 }
diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 985d36cc2..05167e4dc 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -32,3 +32,31 @@ 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);
 }
+
+void
+rte_mcfg_tailq_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->qlock);
+}
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index ca2a7d32a..dc2c13caa 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -58,7 +58,7 @@ rte_dump_tailq(FILE *f)
 
 	mcfg = rte_eal_get_configuration()->mem_config;
 
-	rte_rwlock_read_lock(&mcfg->qlock);
+	rte_mcfg_tailq_read_lock();
 	for (i = 0; i < RTE_MAX_TAILQ; i++) {
 		const struct rte_tailq_head *tailq = &mcfg->tailq_head[i];
 		const struct rte_tailq_entry_head *head = &tailq->tailq_head;
@@ -66,7 +66,7 @@ rte_dump_tailq(FILE *f)
 		fprintf(f, "Tailq %u: qname:<%s>, tqh_first:%p, tqh_last:%p\n",
 			i, tailq->name, head->tqh_first, head->tqh_last);
 	}
-	rte_rwlock_read_unlock(&mcfg->qlock);
+	rte_mcfg_tailq_read_unlock();
 }
 
 static struct rte_tailq_head *
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index bf0c74e07..28cbf2dde 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -446,11 +446,6 @@ typedef void	(*rte_usage_hook_t)(const char * prgname);
 rte_usage_hook_t
 rte_set_application_usage_hook(rte_usage_hook_t usage_func);
 
-/**
- * macro to get the lock of tailq in mem_config
- */
-#define RTE_EAL_TAILQ_RWLOCK         (&rte_eal_get_configuration()->mem_config->qlock)
-
 /**
  * macro to get the multiple lock of mempool shared by multiple-instance
  */
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index a554518ef..240fa150b 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -124,6 +124,30 @@ rte_mcfg_mem_write_lock(void);
 void
 rte_mcfg_mem_write_unlock(void);
 
+/**
+ * Lock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_mcfg_tailq_read_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_mcfg_tailq_read_unlock(void);
+
+/**
+ * Lock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_mcfg_tailq_write_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_mcfg_tailq_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 754060dc9..d78a3a8b9 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -296,6 +296,10 @@ DPDK_19.08 {
 	rte_mcfg_mem_read_unlock;
 	rte_mcfg_mem_write_lock;
 	rte_mcfg_mem_write_unlock;
+	rte_mcfg_tailq_read_lock;
+	rte_mcfg_tailq_read_unlock;
+	rte_mcfg_tailq_write_lock;
+	rte_mcfg_tailq_write_unlock;
 	rte_rand;
 	rte_srand;
 
diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index 14e493bc3..b808ce99f 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -532,7 +532,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	num_chunks_shift = rte_bsf32(num_chunks);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/*
 	 * Guarantee there's no existing: this is normally already checked
@@ -685,7 +685,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	te->data = (void *) table;
 	TAILQ_INSERT_TAIL(efd_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	snprintf(ring_name, sizeof(ring_name), "HT_%s", table->name);
 	/* Create ring (Dummy slot index is not enqueued) */
@@ -705,7 +705,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	return table;
 
 error_unlock_exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_efd_free(table);
 
 	return NULL;
@@ -720,7 +720,7 @@ rte_efd_find_existing(const char *name)
 
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, efd_list, next)
 	{
@@ -728,7 +728,7 @@ rte_efd_find_existing(const char *name)
 		if (strncmp(name, table->name, RTE_EFD_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -751,7 +751,7 @@ rte_efd_free(struct rte_efd_table *table)
 		rte_free(table->chunks[socket_id]);
 
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH_SAFE(te, efd_list, next, temp) {
 		if (te->data == (void *) table) {
@@ -761,7 +761,7 @@ rte_efd_free(struct rte_efd_table *table)
 		}
 	}
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_ring_free(table->free_slots);
 	rte_free(table->offline_chunks);
 	rte_free(table->keys);
diff --git a/lib/librte_eventdev/rte_event_ring.c b/lib/librte_eventdev/rte_event_ring.c
index 16d02a953..50190de01 100644
--- a/lib/librte_eventdev/rte_event_ring.c
+++ b/lib/librte_eventdev/rte_event_ring.c
@@ -72,7 +72,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/*
 	 * reserve a memory zone for this ring. If we can't get rte_config or
@@ -89,7 +89,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 			if (rte_memzone_free(mz) != 0)
 				RTE_LOG(ERR, RING, "Cannot free memzone\n");
 			rte_free(te);
-			rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+			rte_mcfg_tailq_write_unlock();
 			return NULL;
 		}
 
@@ -102,7 +102,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return r;
 }
@@ -118,7 +118,7 @@ rte_event_ring_lookup(const char *name)
 	ring_list = RTE_TAILQ_CAST(rte_event_ring_tailq.head,
 			rte_event_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		r = (struct rte_event_ring *) te->data;
@@ -126,7 +126,7 @@ rte_event_ring_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -163,7 +163,7 @@ rte_event_ring_free(struct rte_event_ring *r)
 
 	ring_list = RTE_TAILQ_CAST(rte_event_ring_tailq.head,
 			rte_event_ring_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, ring_list, next) {
@@ -172,13 +172,13 @@ rte_event_ring_free(struct rte_event_ring *r)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(ring_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 }
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 51198b477..47cd0da5b 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -52,13 +52,13 @@ rte_hash_find_existing(const char *name)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, hash_list, next) {
 		h = (struct rte_hash *) te->data;
 		if (strncmp(name, h->name, RTE_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -239,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	snprintf(hash_name, sizeof(hash_name), "HT_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing: this is normally already checked
 	 * by ring creation above */
@@ -437,11 +437,11 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	te->data = (void *) h;
 	TAILQ_INSERT_TAIL(hash_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return h;
 err_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 err:
 	rte_ring_free(r);
 	rte_ring_free(r_ext);
@@ -466,7 +466,7 @@ rte_hash_free(struct rte_hash *h)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, hash_list, next) {
@@ -475,13 +475,13 @@ rte_hash_free(struct rte_hash *h)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	if (h->use_local_cache)
 		rte_free(h->local_free_slots);
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index 9360f7981..db118c930 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -50,13 +50,13 @@ rte_fbk_hash_find_existing(const char *name)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
 		h = (struct rte_fbk_hash_table *) te->data;
 		if (strncmp(name, h->name, RTE_FBK_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 	if (te == NULL) {
 		rte_errno = ENOENT;
 		return NULL;
@@ -103,7 +103,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 
 	snprintf(hash_name, sizeof(hash_name), "FBK_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -165,7 +165,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 	TAILQ_INSERT_TAIL(fbk_hash_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return ht;
 }
@@ -188,7 +188,7 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -197,13 +197,13 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(fbk_hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(ht);
 	rte_free(te);
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 00104a35d..309e45918 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -214,7 +214,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	kni = __rte_kni_get(conf->name);
 	if (kni != NULL) {
@@ -304,7 +304,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 	TAILQ_INSERT_TAIL(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	/* Allocate mbufs and then put them into alloc_q */
 	kni_allocate_mbufs(kni);
@@ -318,7 +318,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 kni_fail:
 	rte_free(te);
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return NULL;
 }
@@ -381,7 +381,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, kni_list, next) {
 		if (te->data == kni)
@@ -399,7 +399,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	TAILQ_REMOVE(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	/* mbufs in all fifo should be released, except request/response */
 
@@ -423,7 +423,7 @@ rte_kni_release(struct rte_kni *kni)
 	return 0;
 
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return -1;
 }
@@ -640,11 +640,11 @@ rte_kni_get(const char *name)
 	if (name == NULL || name[0] == '\0')
 		return NULL;
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	kni = __rte_kni_get(name);
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	return kni;
 }
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index 6b7b28a2e..b91f74216 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -97,13 +97,13 @@ rte_lpm_find_existing_v20(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -123,13 +123,13 @@ rte_lpm_find_existing_v1604(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -170,7 +170,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	/* Determine the amount of memory to allocate. */
 	mem_size = sizeof(*lpm) + (sizeof(lpm->rules_tbl[0]) * max_rules);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -212,7 +212,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return lpm;
 }
@@ -247,7 +247,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	tbl8s_size = (sizeof(struct rte_lpm_tbl_entry) *
 			RTE_LPM_TBL8_GROUP_NUM_ENTRIES * config->number_tbl8s);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -315,7 +315,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return lpm;
 }
@@ -339,7 +339,7 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -349,7 +349,7 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm);
 	rte_free(te);
@@ -368,7 +368,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -378,7 +378,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm->tbl8);
 	rte_free(lpm->rules_tbl);
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index a91803113..5af74a539 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -316,7 +316,7 @@ rte_lpm6_create(const char *name, int socket_id,
 	mem_size = sizeof(*lpm) + (sizeof(lpm->tbl8[0]) *
 			RTE_LPM6_TBL8_GROUP_NUM_ENTRIES * config->number_tbl8s);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* Guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -363,11 +363,11 @@ rte_lpm6_create(const char *name, int socket_id,
 	te->data = (void *) lpm;
 
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return lpm;
 
 fail:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 fail_wo_unlock:
 	rte_free(tbl8_hdrs);
@@ -389,13 +389,13 @@ rte_lpm6_find_existing(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = (struct rte_lpm6 *) te->data;
 		if (strncmp(name, l->name, RTE_LPM6_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -420,7 +420,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -431,7 +431,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm->tbl8_hdrs);
 	rte_free(lpm->tbl8_pool);
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index fd228f4ba..efed28dd9 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -32,13 +32,13 @@ rte_member_find_existing(const char *name)
 
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, member_list, next) {
 		setsum = (struct rte_member_setsum *) te->data;
 		if (strncmp(name, setsum->name, RTE_MEMBER_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -56,17 +56,17 @@ rte_member_free(struct rte_member_setsum *setsum)
 	if (setsum == NULL)
 		return;
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_FOREACH(te, member_list, next) {
 		if (te->data == (void *)setsum)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 	TAILQ_REMOVE(member_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	switch (setsum->type) {
 	case RTE_MEMBER_TYPE_HT:
@@ -105,7 +105,7 @@ rte_member_create(const struct rte_member_parameters *params)
 
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, member_list, next) {
 		setsum = te->data;
@@ -159,13 +159,13 @@ rte_member_create(const struct rte_member_parameters *params)
 
 	te->data = (void *)setsum;
 	TAILQ_INSERT_TAIL(member_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return setsum;
 
 error_unlock_exit:
 	rte_free(te);
 	rte_free(setsum);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return NULL;
 }
 
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 69bd2a65c..238287a01 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -711,7 +711,7 @@ rte_mempool_free(struct rte_mempool *mp)
 		return;
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, mempool_list, next) {
 		if (te->data == (void *)mp)
@@ -722,7 +722,7 @@ rte_mempool_free(struct rte_mempool *mp)
 		TAILQ_REMOVE(mempool_list, te, next);
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_mempool_free_memchunks(mp);
 	rte_mempool_ops_free(mp);
@@ -898,9 +898,9 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 
 	te->data = mp;
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(mempool_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
 
 	return mp;
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index 3a4a1b0a0..ae6e3f578 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -119,7 +119,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, reorder_list, next) {
@@ -152,7 +152,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 	}
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return b;
 }
 
@@ -193,7 +193,7 @@ rte_reorder_free(struct rte_reorder_buffer *b)
 
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, reorder_list, next) {
@@ -201,13 +201,13 @@ rte_reorder_free(struct rte_reorder_buffer *b)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(reorder_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_reorder_free_mbufs(b);
 
@@ -229,13 +229,13 @@ rte_reorder_find_existing(const char *name)
 
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, reorder_list, next) {
 		b = (struct rte_reorder_buffer *) te->data;
 		if (strncmp(name, b->name, RTE_REORDER_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index b89ecf999..9ea26a631 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -147,7 +147,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* reserve a memory zone for this ring. If we can't get rte_config or
 	 * we are secondary process, the memzone_reserve function will set
@@ -169,7 +169,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
 		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return r;
 }
@@ -200,7 +200,7 @@ rte_ring_free(struct rte_ring *r)
 	}
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, ring_list, next) {
@@ -209,13 +209,13 @@ rte_ring_free(struct rte_ring *r)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(ring_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 }
@@ -245,13 +245,13 @@ rte_ring_list_dump(FILE *f)
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		rte_ring_dump(f, (struct rte_ring *) te->data);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 }
 
 /* search a ring from its name */
@@ -264,7 +264,7 @@ rte_ring_lookup(const char *name)
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		r = (struct rte_ring *) te->data;
@@ -272,7 +272,7 @@ rte_ring_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index 60f63a65b..2cc7e8e16 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -84,13 +84,13 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	mz = rte_memzone_reserve_aligned(mz_name, sz, socket_id,
 					 0, __alignof__(*s));
 	if (mz == NULL) {
 		STACK_LOG_ERR("Cannot reserve stack memzone!\n");
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		rte_free(te);
 		return NULL;
 	}
@@ -102,7 +102,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 	/* Store the name for later lookups */
 	ret = strlcpy(s->name, name, sizeof(s->name));
 	if (ret < 0 || ret >= (int)sizeof(s->name)) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 
 		rte_errno = ENAMETOOLONG;
 		rte_free(te);
@@ -120,7 +120,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 
 	TAILQ_INSERT_TAIL(stack_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return s;
 }
@@ -135,7 +135,7 @@ rte_stack_free(struct rte_stack *s)
 		return;
 
 	stack_list = RTE_TAILQ_CAST(rte_stack_tailq.head, rte_stack_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, stack_list, next) {
@@ -144,13 +144,13 @@ rte_stack_free(struct rte_stack *s)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(stack_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 
@@ -171,7 +171,7 @@ rte_stack_lookup(const char *name)
 
 	stack_list = RTE_TAILQ_CAST(rte_stack_tailq.head, rte_stack_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, stack_list, next) {
 		r = (struct rte_stack *) te->data;
@@ -179,7 +179,7 @@ rte_stack_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v4 3/8] eal: add new API to lock/unlock mempool list
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
                       ` (4 preceding siblings ...)
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 2/8] eal: add EAL tailq list lock/unlock API Anatoly Burakov
@ 2019-07-05 13:10     ` Anatoly Burakov
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 4/8] eal: hide shared memory config Anatoly Burakov
                       ` (4 subsequent siblings)
  10 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 13:10 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, Andrew Rybchenko, thomas, david.marchand, stephen

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, and search-and-replace all usages.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/common/eal_common_mcfg.c       | 28 +++++++++++++++++++
 lib/librte_eal/common/include/rte_eal.h       |  5 ----
 .../common/include/rte_eal_memconfig.h        | 24 ++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  4 +++
 lib/librte_mempool/rte_mempool.c              | 18 ++++++------
 5 files changed, 65 insertions(+), 14 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 05167e4dc..ba2bc37b7 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -60,3 +60,31 @@ rte_mcfg_tailq_write_unlock(void)
 	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	rte_rwlock_write_unlock(&mcfg->qlock);
 }
+
+void
+rte_mcfg_mempool_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->mplock);
+}
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index 28cbf2dde..34245b053 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -446,11 +446,6 @@ typedef void	(*rte_usage_hook_t)(const char * prgname);
 rte_usage_hook_t
 rte_set_application_usage_hook(rte_usage_hook_t usage_func);
 
-/**
- * macro to get the multiple lock of mempool shared by multiple-instance
- */
-#define RTE_EAL_MEMPOOL_RWLOCK            (&rte_eal_get_configuration()->mem_config->mplock)
-
 /**
  * Whether EAL is using huge pages (disabled by --no-huge option).
  * The no-huge mode cannot be used with UIO poll-mode drivers like igb/ixgbe.
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index 240fa150b..58dcbb96d 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_mcfg_tailq_write_lock(void);
 void
 rte_mcfg_tailq_write_unlock(void);
 
+/**
+ * Lock the internal EAL Mempool list for shared access.
+ */
+void
+rte_mcfg_mempool_read_lock(void);
+
+/**
+ * Unlock the internal EAL Mempool list for shared access.
+ */
+void
+rte_mcfg_mempool_read_unlock(void);
+
+/**
+ * Lock the internal EAL Mempool list for exclusive access.
+ */
+void
+rte_mcfg_mempool_write_lock(void);
+
+/**
+ * Unlock the internal EAL Mempool list for exclusive access.
+ */
+void
+rte_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 d78a3a8b9..cc4ef04a0 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -296,6 +296,10 @@ DPDK_19.08 {
 	rte_mcfg_mem_read_unlock;
 	rte_mcfg_mem_write_lock;
 	rte_mcfg_mem_write_unlock;
+	rte_mcfg_mempool_read_lock;
+	rte_mcfg_mempool_read_unlock;
+	rte_mcfg_mempool_write_lock;
+	rte_mcfg_mempool_write_unlock;
 	rte_mcfg_tailq_read_lock;
 	rte_mcfg_tailq_read_unlock;
 	rte_mcfg_tailq_write_lock;
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 238287a01..5c688d456 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -830,7 +830,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_lock();
 
 	/*
 	 * reserve a memory zone for this mempool: private data is
@@ -901,12 +901,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(mempool_list, te, next);
 	rte_mcfg_tailq_write_unlock();
-	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_unlock();
 
 	return mp;
 
 exit_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_unlock();
 	rte_free(te);
 	rte_mempool_free(mp);
 	return NULL;
@@ -1268,14 +1268,14 @@ rte_mempool_list_dump(FILE *f)
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH(te, mempool_list, next) {
 		mp = (struct rte_mempool *) te->data;
 		rte_mempool_dump(f, mp);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 }
 
 /* search a mempool from its name */
@@ -1288,7 +1288,7 @@ rte_mempool_lookup(const char *name)
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH(te, mempool_list, next) {
 		mp = (struct rte_mempool *) te->data;
@@ -1296,7 +1296,7 @@ rte_mempool_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -1315,11 +1315,11 @@ void rte_mempool_walk(void (*func)(struct rte_mempool *, void *),
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH_SAFE(te, mempool_list, next, tmp_te) {
 		(*func)((struct rte_mempool *) te->data, arg);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v4 4/8] eal: hide shared memory config
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
                       ` (5 preceding siblings ...)
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 3/8] eal: add new API to lock/unlock mempool list Anatoly Burakov
@ 2019-07-05 13:10     ` Anatoly Burakov
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 5/8] eal: remove packed attribute from mcfg structure Anatoly Burakov
                       ` (3 subsequent siblings)
  10 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 13:10 UTC (permalink / raw)
  To: dev
  Cc: Neil Horman, John McNamara, Marko Kovacevic, Konstantin Ananyev,
	David Hunt, Bruce Richardson, Byron Marohn, Pablo de Lara Guarch,
	Yipeng Wang, Sameh Gobriel, Vladimir Medvedkin, Olivier Matz,
	Andrew Rybchenko, Honnappa Nagarahalli, Reshma Pattan, thomas,
	david.marchand, stephen

Now that everything that has ever accessed the shared memory
config is doing so through the public API's, we can make it
internal. Since we're removing quite a few headers from
rte_eal_memconfig.h, we need to add them back in places
where this header is used.

This bumps the ABI, so also change all build files and make
update documentation.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_fbarray.c                       |  1 +
 app/test/test_memzone.c                       |  1 +
 app/test/test_tailq.c                         |  1 +
 doc/guides/rel_notes/deprecation.rst          |  3 -
 doc/guides/rel_notes/release_19_08.rst        |  8 +-
 drivers/bus/pci/linux/pci_vfio.c              |  1 +
 lib/librte_acl/rte_acl.c                      |  2 +
 lib/librte_distributor/rte_distributor.c      |  1 +
 lib/librte_distributor/rte_distributor_v20.c  |  1 +
 lib/librte_eal/common/eal_common_mcfg.c       |  2 +
 lib/librte_eal/common/eal_common_memory.c     |  1 +
 lib/librte_eal/common/eal_common_memzone.c    |  1 +
 lib/librte_eal/common/eal_common_tailqs.c     |  1 +
 lib/librte_eal/common/eal_memcfg.h            | 80 ++++++++++++++++
 .../common/include/rte_eal_memconfig.h        | 95 +------------------
 lib/librte_eal/common/include/rte_fbarray.h   |  1 -
 lib/librte_eal/common/include/rte_memory.h    | 24 ++++-
 lib/librte_eal/common/malloc_heap.c           |  2 +
 lib/librte_eal/common/malloc_mp.c             |  1 +
 lib/librte_eal/common/rte_malloc.c            |  1 +
 lib/librte_eal/freebsd/eal/Makefile           |  2 +-
 lib/librte_eal/freebsd/eal/eal_memory.c       |  1 +
 lib/librte_eal/linux/eal/Makefile             |  2 +-
 lib/librte_eal/linux/eal/eal.c                |  1 +
 lib/librte_eal/linux/eal/eal_memalloc.c       |  1 +
 lib/librte_eal/linux/eal/eal_memory.c         |  1 +
 lib/librte_eal/linux/eal/eal_vfio.c           |  1 +
 lib/librte_eal/meson.build                    |  2 +-
 lib/librte_efd/rte_efd.c                      |  1 +
 lib/librte_hash/rte_cuckoo_hash.c             |  1 +
 lib/librte_hash/rte_fbk_hash.c                |  1 +
 lib/librte_lpm/rte_lpm.c                      |  1 +
 lib/librte_lpm/rte_lpm6.c                     |  1 +
 lib/librte_member/rte_member.c                |  1 +
 lib/librte_mempool/rte_mempool.c              |  1 +
 lib/librte_rcu/rte_rcu_qsbr.h                 |  1 +
 lib/librte_reorder/rte_reorder.c              |  1 +
 lib/librte_ring/rte_ring.c                    |  1 +
 38 files changed, 148 insertions(+), 101 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_memcfg.h

diff --git a/app/test/test_fbarray.c b/app/test/test_fbarray.c
index d2b041887..a691bf445 100644
--- a/app/test/test_fbarray.c
+++ b/app/test/test_fbarray.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <limits.h>
diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index 9fe465e62..7501b63c5 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -19,6 +19,7 @@
 #include <rte_errno.h>
 #include <rte_malloc.h>
 #include "../../lib/librte_eal/common/malloc_elem.h"
+#include "../../lib/librte_eal/common/eal_memcfg.h"
 
 #include "test.h"
 
diff --git a/app/test/test_tailq.c b/app/test/test_tailq.c
index a4ecea2d8..7c9b69fdb 100644
--- a/app/test/test_tailq.c
+++ b/app/test/test_tailq.c
@@ -12,6 +12,7 @@
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
 #include <rte_string_fns.h>
+#include <rte_tailq.h>
 
 #include "test.h"
 
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index e2721fad6..583217da8 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -23,9 +23,6 @@ Deprecation Notices
 * eal: The function ``rte_eal_remote_launch`` will return new error codes
   after read or write error on the pipe, instead of calling ``rte_panic``.
 
-* eal: the ``rte_mem_config`` struct will be made private to remove it from the
-  externally visible ABI and allow it to be updated in the future.
-
 * eal: both declaring and identifying devices will be streamlined in v18.11.
   New functions will appear to query a specific port from buses, classes of
   device and device drivers. Device declaration will be made coherent with the
diff --git a/doc/guides/rel_notes/release_19_08.rst b/doc/guides/rel_notes/release_19_08.rst
index 21934bf01..cc6dfa33f 100644
--- a/doc/guides/rel_notes/release_19_08.rst
+++ b/doc/guides/rel_notes/release_19_08.rst
@@ -172,6 +172,10 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+* The ``rte_mem_config`` structure has been made private. The new accessor
+  ``rte_mcfg_*`` functions were introduced to provide replacement for direct
+  access to the shared mem config.
+
 * The network structures, definitions and functions have
   been prefixed by ``rte_`` to resolve conflicts with libc headers.
 
@@ -201,6 +205,8 @@ ABI Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+* The ``rte_mem_config`` structure has been made private.
+
 * eventdev: Event based Rx adapter callback
 
   The mbuf pointer array in the event eth Rx adapter callback
@@ -246,7 +252,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_compressdev.so.1
      librte_cryptodev.so.7
      librte_distributor.so.1
-     librte_eal.so.10
+   + librte_eal.so.11
      librte_efd.so.1
      librte_ethdev.so.12
    + librte_eventdev.so.7
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index ebf6ccd3c..1ceb1c07b 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -20,6 +20,7 @@
 #include <rte_eal.h>
 #include <rte_bus.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "eal_filesystem.h"
 
diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index 7ff11d25f..bd7247cc3 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -4,6 +4,8 @@
 
 #include <rte_string_fns.h>
 #include <rte_acl.h>
+#include <rte_tailq.h>
+
 #include "acl.h"
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 9eb78b330..0a3213bbf 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -14,6 +14,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_private.h"
 #include "rte_distributor.h"
diff --git a/lib/librte_distributor/rte_distributor_v20.c b/lib/librte_distributor/rte_distributor_v20.c
index 1fc03b971..cdc0969a8 100644
--- a/lib/librte_distributor/rte_distributor_v20.c
+++ b/lib/librte_distributor/rte_distributor_v20.c
@@ -13,6 +13,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_v20.h"
 #include "rte_distributor_private.h"
diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index ba2bc37b7..337890a61 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -5,6 +5,8 @@
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
 
+#include "eal_memcfg.h"
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index fe22b139b..19ea47570 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -24,6 +24,7 @@
 #include "eal_memalloc.h"
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
+#include "eal_memcfg.h"
 #include "malloc_heap.h"
 
 /*
diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
index 521ad7ca1..ef6c909cb 100644
--- a/lib/librte_eal/common/eal_common_memzone.c
+++ b/lib/librte_eal/common/eal_common_memzone.c
@@ -24,6 +24,7 @@
 #include "malloc_heap.h"
 #include "malloc_elem.h"
 #include "eal_private.h"
+#include "eal_memcfg.h"
 
 static inline const struct rte_memzone *
 memzone_lookup_thread_unsafe(const char *name)
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index dc2c13caa..ead06897b 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -23,6 +23,7 @@
 #include <rte_debug.h>
 
 #include "eal_private.h"
+#include "eal_memcfg.h"
 
 TAILQ_HEAD(rte_tailq_elem_head, rte_tailq_elem);
 /* local tailq list */
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
new file mode 100644
index 000000000..74f6159c6
--- /dev/null
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef EAL_MEMCFG_H
+#define EAL_MEMCFG_H
+
+#include <rte_config.h>
+#include <rte_eal_memconfig.h>
+#include <rte_malloc_heap.h>
+#include <rte_memory.h>
+#include <rte_memzone.h>
+#include <rte_pause.h>
+#include <rte_rwlock.h>
+#include <rte_tailq.h>
+
+/**
+ * Memory configuration shared across multiple processes.
+ */
+struct rte_mem_config {
+	volatile uint32_t magic;   /**< Magic number - sanity check. */
+
+	/* memory topology */
+	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
+	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
+
+	/**
+	 * current lock nest order
+	 *  - qlock->mlock (ring/hash/lpm)
+	 *  - mplock->qlock->mlock (mempool)
+	 * Notice:
+	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
+	 */
+	rte_rwlock_t mlock;   /**< used by memzones for thread safety. */
+	rte_rwlock_t qlock;   /**< used by tailqs for thread safety. */
+	rte_rwlock_t mplock;  /**< used by mempool library for thread safety. */
+
+	rte_rwlock_t memory_hotplug_lock;
+	/**< Indicates whether memory hotplug request is in progress. */
+
+	/* memory segments and zones */
+	struct rte_fbarray memzones; /**< Memzone descriptors. */
+
+	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
+	/**< List of dynamic arrays holding memsegs */
+
+	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ];
+	/**< Tailqs for objects */
+
+	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
+	/**< DPDK malloc heaps */
+
+	int next_socket_id; /**< Next socket ID for external malloc heap */
+
+	/* rte_mem_config has to be mapped at the exact same address in all
+	 * processes, so we need to store it.
+	 */
+	uint64_t mem_cfg_addr; /**< Address of this structure in memory. */
+
+	/* Primary and secondary processes cannot run with different legacy or
+	 * single file segments options, so to avoid having to specify these
+	 * options to all processes, store them in shared config and update the
+	 * internal config at init time.
+	 */
+	uint32_t legacy_mem; /**< stored legacy mem parameter. */
+	uint32_t single_file_segments;
+	/**< stored single file segments parameter. */
+
+	uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
+} __attribute__((packed));
+
+static inline void
+rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
+{
+	/* wait until shared mem_config finish initialising */
+	while (mcfg->magic != RTE_MAGIC)
+		rte_pause();
+}
+
+#endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index 58dcbb96d..dc61a6fed 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -5,101 +5,16 @@
 #ifndef _RTE_EAL_MEMCONFIG_H_
 #define _RTE_EAL_MEMCONFIG_H_
 
-#include <rte_config.h>
-#include <rte_tailq.h>
-#include <rte_memory.h>
-#include <rte_memzone.h>
-#include <rte_malloc_heap.h>
-#include <rte_rwlock.h>
-#include <rte_pause.h>
-#include <rte_fbarray.h>
+/**
+ * @file
+ *
+ * This API allows access to EAL shared memory configuration through an API.
+ */
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/**
- * memseg list is a special case as we need to store a bunch of other data
- * together with the array itself.
- */
-struct rte_memseg_list {
-	RTE_STD_C11
-	union {
-		void *base_va;
-		/**< Base virtual address for this memseg list. */
-		uint64_t addr_64;
-		/**< Makes sure addr is always 64-bits */
-	};
-	uint64_t page_sz; /**< Page size for all memsegs in this list. */
-	int socket_id; /**< Socket ID for all memsegs in this list. */
-	volatile uint32_t version; /**< version number for multiprocess sync. */
-	size_t len; /**< Length of memory area covered by this memseg list. */
-	unsigned int external; /**< 1 if this list points to external memory */
-	struct rte_fbarray memseg_arr;
-};
-
-/**
- * the structure for the memory configuration for the RTE.
- * Used by the rte_config structure. It is separated out, as for multi-process
- * support, the memory details should be shared across instances
- */
-struct rte_mem_config {
-	volatile uint32_t magic;   /**< Magic number - Sanity check. */
-
-	/* memory topology */
-	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
-	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
-
-	/**
-	 * current lock nest order
-	 *  - qlock->mlock (ring/hash/lpm)
-	 *  - mplock->qlock->mlock (mempool)
-	 * Notice:
-	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
-	 */
-	rte_rwlock_t mlock;   /**< only used by memzone LIB for thread-safe. */
-	rte_rwlock_t qlock;   /**< used for tailq operation for thread safe. */
-	rte_rwlock_t mplock;  /**< only used by mempool LIB for thread-safe. */
-
-	rte_rwlock_t memory_hotplug_lock;
-	/**< indicates whether memory hotplug request is in progress. */
-
-	/* memory segments and zones */
-	struct rte_fbarray memzones; /**< Memzone descriptors. */
-
-	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
-	/**< list of dynamic arrays holding memsegs */
-
-	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ]; /**< Tailqs for objects */
-
-	/* Heaps of Malloc */
-	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
-
-	/* next socket ID for external malloc heap */
-	int next_socket_id;
-
-	/* address of mem_config in primary process. used to map shared config into
-	 * exact same address the primary process maps it.
-	 */
-	uint64_t mem_cfg_addr;
-
-	/* legacy mem and single file segments options are shared */
-	uint32_t legacy_mem;
-	uint32_t single_file_segments;
-
-	/* keeps the more restricted dma mask */
-	uint8_t dma_maskbits;
-} __attribute__((__packed__));
-
-
-inline static void
-rte_eal_mcfg_wait_complete(struct rte_mem_config* mcfg)
-{
-	/* wait until shared mem_config finish initialising */
-	while(mcfg->magic != RTE_MAGIC)
-		rte_pause();
-}
-
 /**
  * Lock the internal EAL shared memory configuration for shared access.
  */
diff --git a/lib/librte_eal/common/include/rte_fbarray.h b/lib/librte_eal/common/include/rte_fbarray.h
index d0af2d8c7..6dccdbec9 100644
--- a/lib/librte_eal/common/include/rte_fbarray.h
+++ b/lib/librte_eal/common/include/rte_fbarray.h
@@ -34,7 +34,6 @@
 extern "C" {
 #endif
 
-#include <stdbool.h>
 #include <stdio.h>
 
 #include <rte_compat.h>
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 44cbe6fd2..ca34a10c3 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -22,9 +22,7 @@ extern "C" {
 #include <rte_common.h>
 #include <rte_compat.h>
 #include <rte_config.h>
-
-/* forward declaration for pointers */
-struct rte_memseg_list;
+#include <rte_fbarray.h>
 
 __extension__
 enum rte_page_sizes {
@@ -104,6 +102,26 @@ struct rte_memseg {
 	uint32_t flags;             /**< Memseg-specific flags */
 } __rte_packed;
 
+/**
+ * memseg list is a special case as we need to store a bunch of other data
+ * together with the array itself.
+ */
+struct rte_memseg_list {
+	RTE_STD_C11
+	union {
+		void *base_va;
+		/**< Base virtual address for this memseg list. */
+		uint64_t addr_64;
+		/**< Makes sure addr is always 64-bits */
+	};
+	uint64_t page_sz; /**< Page size for all memsegs in this list. */
+	int socket_id; /**< Socket ID for all memsegs in this list. */
+	volatile uint32_t version; /**< version number for multiprocess sync. */
+	size_t len; /**< Length of memory area covered by this memseg list. */
+	unsigned int external; /**< 1 if this list points to external memory */
+	struct rte_fbarray memseg_arr;
+};
+
 /**
  * Lock page in physical memory and prevent from swapping.
  *
diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index f1d31de0d..634ca212f 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -20,11 +20,13 @@
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
 #include <rte_memcpy.h>
+#include <rte_memzone.h>
 #include <rte_atomic.h>
 #include <rte_fbarray.h>
 
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "malloc_elem.h"
 #include "malloc_heap.h"
 #include "malloc_mp.h"
diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c
index 7c6112c4e..1f212f834 100644
--- a/lib/librte_eal/common/malloc_mp.c
+++ b/lib/librte_eal/common/malloc_mp.c
@@ -10,6 +10,7 @@
 #include <rte_string_fns.h>
 
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 
 #include "malloc_elem.h"
 #include "malloc_mp.h"
diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index 2cad7beaa..fecd9a964 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -25,6 +25,7 @@
 #include "malloc_elem.h"
 #include "malloc_heap.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 
 
 /* Free the memory space back to heap */
diff --git a/lib/librte_eal/freebsd/eal/Makefile b/lib/librte_eal/freebsd/eal/Makefile
index eb921275e..89131ea89 100644
--- a/lib/librte_eal/freebsd/eal/Makefile
+++ b/lib/librte_eal/freebsd/eal/Makefile
@@ -22,7 +22,7 @@ LDLIBS += -lrte_kvargs
 
 EXPORT_MAP := ../../rte_eal_version.map
 
-LIBABIVER := 10
+LIBABIVER := 11
 
 # specific to freebsd exec-env
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) := eal.c
diff --git a/lib/librte_eal/freebsd/eal/eal_memory.c b/lib/librte_eal/freebsd/eal/eal_memory.c
index 4b092e1f2..9b9a0577a 100644
--- a/lib/librte_eal/freebsd/eal/eal_memory.c
+++ b/lib/librte_eal/freebsd/eal/eal_memory.c
@@ -18,6 +18,7 @@
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
+#include "eal_memcfg.h"
 
 #define EAL_PAGE_SIZE (sysconf(_SC_PAGESIZE))
 
diff --git a/lib/librte_eal/linux/eal/Makefile b/lib/librte_eal/linux/eal/Makefile
index dfe8e9a49..0f5725e64 100644
--- a/lib/librte_eal/linux/eal/Makefile
+++ b/lib/librte_eal/linux/eal/Makefile
@@ -10,7 +10,7 @@ ARCH_DIR ?= $(RTE_ARCH)
 EXPORT_MAP := ../../rte_eal_version.map
 VPATH += $(RTE_SDK)/lib/librte_eal/common/arch/$(ARCH_DIR)
 
-LIBABIVER := 10
+LIBABIVER := 11
 
 VPATH += $(RTE_SDK)/lib/librte_eal/common
 
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 8a0b387ce..f974cec1c 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -57,6 +57,7 @@
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
+#include "eal_memcfg.h"
 #include "eal_options.h"
 #include "eal_vfio.h"
 #include "hotplug_mp.h"
diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c
index 2019636fb..1f6a7c18f 100644
--- a/lib/librte_eal/linux/eal/eal_memalloc.c
+++ b/lib/librte_eal/linux/eal/eal_memalloc.c
@@ -44,6 +44,7 @@
 #include "eal_filesystem.h"
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_private.h"
 
 const int anonymous_hugepages_supported =
diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c
index 1853acea5..9c948a374 100644
--- a/lib/librte_eal/linux/eal/eal_memory.c
+++ b/lib/librte_eal/linux/eal/eal_memory.c
@@ -46,6 +46,7 @@
 
 #include "eal_private.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index 96a03a657..fdc884f70 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -15,6 +15,7 @@
 #include <rte_vfio.h>
 
 #include "eal_filesystem.h"
+#include "eal_memcfg.h"
 #include "eal_vfio.h"
 #include "eal_private.h"
 
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index ccd5b85b8..2751023a9 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -12,7 +12,7 @@ subdir('common') # defines common_sources, common_objs, etc.
 dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env + '/eal')
 
-version = 10  # the version of the EAL API
+version = 11  # the version of the EAL API
 allow_experimental_apis = true
 deps += 'kvargs'
 if dpdk_conf.has('RTE_USE_LIBBSD')
diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index b808ce99f..d3d019578 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -20,6 +20,7 @@
 #include <rte_ring.h>
 #include <rte_jhash.h>
 #include <rte_hash_crc.h>
+#include <rte_tailq.h>
 
 #include "rte_efd.h"
 #if defined(RTE_ARCH_X86)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 47cd0da5b..74d5bbd99 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -27,6 +27,7 @@
 #include <rte_ring.h>
 #include <rte_compat.h>
 #include <rte_vect.h>
+#include <rte_tailq.h>
 
 #include "rte_hash.h"
 #include "rte_cuckoo_hash.h"
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index db118c930..576e8e666 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -20,6 +20,7 @@
 #include <rte_cpuflags.h>
 #include <rte_log.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_fbk_hash.h"
 
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index b91f74216..70c24ac1f 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -21,6 +21,7 @@
 #include <rte_errno.h>
 #include <rte_rwlock.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_lpm.h"
 
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index 5af74a539..9b8aeb972 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -24,6 +24,7 @@
 #include <rte_hash.h>
 #include <assert.h>
 #include <rte_jhash.h>
+#include <rte_tailq.h>
 
 #include "rte_lpm6.h"
 
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index efed28dd9..e0e7f127e 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -10,6 +10,7 @@
 #include <rte_memory.h>
 #include <rte_malloc.h>
 #include <rte_errno.h>
+#include <rte_tailq.h>
 
 #include "rte_member.h"
 #include "rte_member_ht.h"
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 5c688d456..7260ce0be 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -30,6 +30,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_mempool.h"
 
diff --git a/lib/librte_rcu/rte_rcu_qsbr.h b/lib/librte_rcu/rte_rcu_qsbr.h
index 53a5a7165..c80f15c00 100644
--- a/lib/librte_rcu/rte_rcu_qsbr.h
+++ b/lib/librte_rcu/rte_rcu_qsbr.h
@@ -24,6 +24,7 @@
 extern "C" {
 #endif
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <inttypes.h>
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index ae6e3f578..3c9f0e2d0 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -11,6 +11,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
 #include <rte_malloc.h>
+#include <rte_tailq.h>
 
 #include "rte_reorder.h"
 
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index 9ea26a631..b30b2aa7b 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -30,6 +30,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_ring.h"
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v4 5/8] eal: remove packed attribute from mcfg structure
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
                       ` (6 preceding siblings ...)
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 4/8] eal: hide shared memory config Anatoly Burakov
@ 2019-07-05 13:10     ` Anatoly Burakov
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 6/8] eal: uninline wait for mcfg complete function Anatoly Burakov
                       ` (2 subsequent siblings)
  10 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 13:10 UTC (permalink / raw)
  To: dev; +Cc: thomas, david.marchand, stephen

There is no reason to pack the memconfig structure, and doing so
gives out warnings in some static analyzers. Fix it by removing
the packed attributed.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/common/eal_memcfg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 74f6159c6..e5b90e31d 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -67,7 +67,7 @@ struct rte_mem_config {
 	/**< stored single file segments parameter. */
 
 	uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
-} __attribute__((packed));
+};
 
 static inline void
 rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v4 6/8] eal: uninline wait for mcfg complete function
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
                       ` (7 preceding siblings ...)
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 5/8] eal: remove packed attribute from mcfg structure Anatoly Burakov
@ 2019-07-05 13:10     ` Anatoly Burakov
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 7/8] eal: unify and move " Anatoly Burakov
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 8/8] eal: unify internal config initialization Anatoly Burakov
  10 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 13:10 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, thomas, david.marchand, stephen

Currently, the function to wait until config completion is
static inline for no reason. Move its implementation to
an EAL common file.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/common/eal_common_mcfg.c | 10 ++++++++++
 lib/librte_eal/common/eal_memcfg.h      | 10 +++-------
 lib/librte_eal/freebsd/eal/eal.c        |  3 ++-
 lib/librte_eal/linux/eal/eal.c          |  2 +-
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 337890a61..30969c6bf 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -7,6 +7,16 @@
 
 #include "eal_memcfg.h"
 
+void
+eal_mcfg_wait_complete(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	/* wait until shared mem_config finish initialising */
+	while (mcfg->magic != RTE_MAGIC)
+		rte_pause();
+}
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index e5b90e31d..6c08652fe 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -69,12 +69,8 @@ struct rte_mem_config {
 	uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
 };
 
-static inline void
-rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
-{
-	/* wait until shared mem_config finish initialising */
-	while (mcfg->magic != RTE_MAGIC)
-		rte_pause();
-}
+/* wait until primary process initialization is complete */
+void
+eal_mcfg_wait_complete(void);
 
 #endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 71ba380e0..78022f68a 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -52,6 +52,7 @@
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
 #include "eal_options.h"
+#include "eal_memcfg.h"
 
 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
 
@@ -382,7 +383,7 @@ rte_config_init(void)
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
 			return -1;
-		rte_eal_mcfg_wait_complete(rte_config.mem_config);
+		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
 		break;
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index f974cec1c..561a4f3f3 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -506,7 +506,7 @@ rte_config_init(void)
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
 			return -1;
-		rte_eal_mcfg_wait_complete(rte_config.mem_config);
+		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
 		eal_update_internal_config();
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v4 7/8] eal: unify and move mcfg complete function
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
                       ` (8 preceding siblings ...)
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 6/8] eal: uninline wait for mcfg complete function Anatoly Burakov
@ 2019-07-05 13:10     ` Anatoly Burakov
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 8/8] eal: unify internal config initialization Anatoly Burakov
  10 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 13:10 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, thomas, david.marchand, stephen

Currently, mcfg completion function exists in two independent
implementations doing the same thing, which is bug prone.
Unify the two functions and move them into one place.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/common/eal_common_mcfg.c | 14 ++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  4 ++++
 lib/librte_eal/freebsd/eal/eal.c        | 12 +-----------
 lib/librte_eal/linux/eal/eal.c          | 12 +-----------
 4 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 30969c6bf..dc6665d6a 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -5,8 +5,22 @@
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
 
+#include "eal_internal_cfg.h"
 #include "eal_memcfg.h"
 
+void
+eal_mcfg_complete(void)
+{
+	struct rte_config *cfg = rte_eal_get_configuration();
+	struct rte_mem_config *mcfg = cfg->mem_config;
+
+	/* ALL shared mem_config related INIT DONE */
+	if (cfg->process_type == RTE_PROC_PRIMARY)
+		mcfg->magic = RTE_MAGIC;
+
+	internal_config.init_complete = 1;
+}
+
 void
 eal_mcfg_wait_complete(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 6c08652fe..417324aab 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -73,4 +73,8 @@ struct rte_mem_config {
 void
 eal_mcfg_wait_complete(void);
 
+/* set mem config as complete */
+void
+eal_mcfg_complete(void);
+
 #endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 78022f68a..340f7dd6c 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -632,16 +632,6 @@ sync_func(__attribute__((unused)) void *arg)
 	return 0;
 }
 
-inline static void
-rte_eal_mcfg_complete(void)
-{
-	/* ALL shared mem_config related INIT DONE */
-	if (rte_config.process_type == RTE_PROC_PRIMARY)
-		rte_config.mem_config->magic = RTE_MAGIC;
-
-	internal_config.init_complete = 1;
-}
-
 /* return non-zero if hugepages are enabled. */
 int rte_eal_has_hugepages(void)
 {
@@ -919,7 +909,7 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	rte_eal_mcfg_complete();
+	eal_mcfg_complete();
 
 	/* Call each registered callback, if enabled */
 	rte_option_init();
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 561a4f3f3..e15eacffc 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -934,16 +934,6 @@ sync_func(__attribute__((unused)) void *arg)
 	return 0;
 }
 
-inline static void
-rte_eal_mcfg_complete(void)
-{
-	/* ALL shared mem_config related INIT DONE */
-	if (rte_config.process_type == RTE_PROC_PRIMARY)
-		rte_config.mem_config->magic = RTE_MAGIC;
-
-	internal_config.init_complete = 1;
-}
-
 /*
  * Request iopl privilege for all RPL, returns 0 on success
  * iopl() call is mostly for the i386 architecture. For other architectures,
@@ -1267,7 +1257,7 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	rte_eal_mcfg_complete();
+	eal_mcfg_complete();
 
 	/* Call each registered callback, if enabled */
 	rte_option_init();
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v4 8/8] eal: unify internal config initialization
  2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
                       ` (9 preceding siblings ...)
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 7/8] eal: unify and move " Anatoly Burakov
@ 2019-07-05 13:10     ` Anatoly Burakov
  10 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 13:10 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, thomas, david.marchand, stephen

Currently, each EAL will update internal/shared config in their
own way at init, resulting in needless duplication of code and
OS-dependent behavior. Move the functions to a common file and
add missing FreeBSD steps.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/common/eal_common_mcfg.c | 18 ++++++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  8 ++++++++
 lib/librte_eal/freebsd/eal/eal.c        |  2 ++
 lib/librte_eal/linux/eal/eal.c          | 22 ++--------------------
 4 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index dc6665d6a..fe8d2b726 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -31,6 +31,24 @@ eal_mcfg_wait_complete(void)
 		rte_pause();
 }
 
+void
+eal_mcfg_update_internal(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	internal_config.legacy_mem = mcfg->legacy_mem;
+	internal_config.single_file_segments = mcfg->single_file_segments;
+}
+
+void
+eal_mcfg_update_from_internal(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	mcfg->legacy_mem = internal_config.legacy_mem;
+	mcfg->single_file_segments = internal_config.single_file_segments;
+}
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 417324aab..573233896 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -69,6 +69,14 @@ struct rte_mem_config {
 	uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
 };
 
+/* update internal config from shared mem config */
+void
+eal_mcfg_update_internal(void);
+
+/* update shared mem config from internal config */
+void
+eal_mcfg_update_from_internal(void);
+
 /* wait until primary process initialization is complete */
 void
 eal_mcfg_wait_complete(void);
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 340f7dd6c..ec1650c43 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -379,6 +379,7 @@ rte_config_init(void)
 	case RTE_PROC_PRIMARY:
 		if (rte_eal_config_create() < 0)
 			return -1;
+		eal_mcfg_update_from_internal();
 		break;
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
@@ -386,6 +387,7 @@ rte_config_init(void)
 		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
+		eal_mcfg_update_internal();
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index e15eacffc..445d72f0c 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -473,24 +473,6 @@ eal_proc_type_detect(void)
 	return ptype;
 }
 
-/* copies data from internal config to shared config */
-static void
-eal_update_mem_config(void)
-{
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	mcfg->legacy_mem = internal_config.legacy_mem;
-	mcfg->single_file_segments = internal_config.single_file_segments;
-}
-
-/* copies data from shared config to internal config */
-static void
-eal_update_internal_config(void)
-{
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	internal_config.legacy_mem = mcfg->legacy_mem;
-	internal_config.single_file_segments = mcfg->single_file_segments;
-}
-
 /* Sets up rte_config structure with the pointer to shared memory config.*/
 static int
 rte_config_init(void)
@@ -501,7 +483,7 @@ rte_config_init(void)
 	case RTE_PROC_PRIMARY:
 		if (rte_eal_config_create() < 0)
 			return -1;
-		eal_update_mem_config();
+		eal_mcfg_update_from_internal();
 		break;
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
@@ -509,7 +491,7 @@ rte_config_init(void)
 		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
-		eal_update_internal_config();
+		eal_mcfg_update_internal();
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v5 0/9] Make shared memory config non-public
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
@ 2019-07-05 17:26       ` Anatoly Burakov
  2019-07-05 19:30         ` David Marchand
  2019-07-05 21:09         ` Thomas Monjalon
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 1/9] eal: add API to lock/unlock memory hotplug Anatoly Burakov
                         ` (8 subsequent siblings)
  9 siblings, 2 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 17:26 UTC (permalink / raw)
  To: dev; +Cc: thomas, david.marchand, stephen

This patchset removes the shared memory config from public
API, and replaces all usages of said config with new API
calls.

A lot of the patchset is a search-and-replace job and should
be pretty easy to review. The rest are pretty trivial EAL
changes.

v5:
- Accidentally squashed last patch into another patch

v4:
- Rebase on top of latest master
- Squashed more commits
- Added some cleanups
  - Comment cleanup in mem config
  - Moved memseg list struct to rte_memory
- Fixed init in FreeBSD when storing data in config

v3:
- Rebase on top of latest master

v2:
- Collapsed all changes into fewer patches
- Addressed review comments
- Created a new file to store the code
- Changed namespace to "rte_mcfg_"
- Added some unification around config init
- Removed "packed" attribute from mem config
- Removed unnecessary inlining
- Added a check to explicitly forbid running multiprocess
  applications that differ in their DPDK versions

Anatoly Burakov (9):
  eal: add API to lock/unlock memory hotplug
  eal: add EAL tailq list lock/unlock API
  eal: add new API to lock/unlock mempool list
  eal: hide shared memory config
  eal: remove packed attribute from mcfg structure
  eal: uninline wait for mcfg complete function
  eal: unify and move mcfg complete function
  eal: unify internal config initialization
  eal: prevent different primary/secondary process versions

 app/test/test_fbarray.c                       |   1 +
 app/test/test_memzone.c                       |   1 +
 app/test/test_tailq.c                         |   1 +
 doc/guides/rel_notes/deprecation.rst          |   3 -
 doc/guides/rel_notes/release_19_08.rst        |   8 +-
 drivers/bus/fslmc/fslmc_vfio.c                |   8 +-
 drivers/bus/pci/linux/pci_vfio.c              |   1 +
 drivers/net/mlx4/mlx4_mr.c                    |  11 +-
 drivers/net/mlx5/mlx5_mr.c                    |  11 +-
 .../net/virtio/virtio_user/virtio_user_dev.c  |   7 +-
 lib/librte_acl/rte_acl.c                      |  20 +--
 lib/librte_distributor/rte_distributor.c      |   5 +-
 lib/librte_distributor/rte_distributor_v20.c  |   5 +-
 lib/librte_eal/common/eal_common_mcfg.c       | 149 ++++++++++++++++++
 lib/librte_eal/common/eal_common_memory.c     |  44 +++---
 lib/librte_eal/common/eal_common_memzone.c    |   1 +
 lib/librte_eal/common/eal_common_tailqs.c     |   5 +-
 lib/librte_eal/common/eal_memcfg.h            |  94 +++++++++++
 lib/librte_eal/common/include/rte_eal.h       |  10 --
 .../common/include/rte_eal_memconfig.h        | 135 +++++++---------
 lib/librte_eal/common/include/rte_fbarray.h   |   1 -
 lib/librte_eal/common/include/rte_memory.h    |  24 ++-
 lib/librte_eal/common/malloc_heap.c           |  16 +-
 lib/librte_eal/common/malloc_mp.c             |   1 +
 lib/librte_eal/common/meson.build             |   1 +
 lib/librte_eal/common/rte_malloc.c            |  33 ++--
 lib/librte_eal/freebsd/eal/Makefile           |   3 +-
 lib/librte_eal/freebsd/eal/eal.c              |  21 ++-
 lib/librte_eal/freebsd/eal/eal_memory.c       |   1 +
 lib/librte_eal/linux/eal/Makefile             |   3 +-
 lib/librte_eal/linux/eal/eal.c                |  41 ++---
 lib/librte_eal/linux/eal/eal_memalloc.c       |   1 +
 lib/librte_eal/linux/eal/eal_memory.c         |   1 +
 lib/librte_eal/linux/eal/eal_vfio.c           |  17 +-
 lib/librte_eal/meson.build                    |   2 +-
 lib/librte_eal/rte_eal_version.map            |  12 ++
 lib/librte_efd/rte_efd.c                      |  15 +-
 lib/librte_eventdev/rte_event_ring.c          |  16 +-
 lib/librte_hash/rte_cuckoo_hash.c             |  17 +-
 lib/librte_hash/rte_fbk_hash.c                |  15 +-
 lib/librte_kni/rte_kni.c                      |  16 +-
 lib/librte_lpm/rte_lpm.c                      |  25 +--
 lib/librte_lpm/rte_lpm6.c                     |  15 +-
 lib/librte_member/rte_member.c                |  17 +-
 lib/librte_mempool/rte_mempool.c              |  27 ++--
 lib/librte_rcu/rte_rcu_qsbr.h                 |   1 +
 lib/librte_reorder/rte_reorder.c              |  15 +-
 lib/librte_ring/rte_ring.c                    |  19 +--
 lib/librte_stack/rte_stack.c                  |  18 +--
 49 files changed, 575 insertions(+), 339 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_mcfg.c
 create mode 100644 lib/librte_eal/common/eal_memcfg.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v5 1/9] eal: add API to lock/unlock memory hotplug
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 0/9] " Anatoly Burakov
@ 2019-07-05 17:26       ` Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 2/9] eal: add EAL tailq list lock/unlock API Anatoly Burakov
                         ` (7 subsequent siblings)
  9 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 17:26 UTC (permalink / raw)
  To: dev
  Cc: Hemant Agrawal, Shreyansh Jain, Matan Azrad, Shahaf Shuler,
	Yongseok Koh, Maxime Coquelin, Tiwei Bie, Zhihong Wang,
	Bruce Richardson, thomas, david.marchand, stephen

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_*, and search-and-replace all
usages of the locks with the new API.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/fslmc/fslmc_vfio.c                |  8 ++--
 drivers/net/mlx4/mlx4_mr.c                    | 11 +++--
 drivers/net/mlx5/mlx5_mr.c                    | 11 +++--
 .../net/virtio/virtio_user/virtio_user_dev.c  |  7 ++-
 lib/librte_eal/common/eal_common_mcfg.c       | 34 +++++++++++++++
 lib/librte_eal/common/eal_common_memory.c     | 43 ++++++++-----------
 .../common/include/rte_eal_memconfig.h        | 24 +++++++++++
 lib/librte_eal/common/malloc_heap.c           | 14 +++---
 lib/librte_eal/common/meson.build             |  1 +
 lib/librte_eal/common/rte_malloc.c            | 32 ++++++--------
 lib/librte_eal/freebsd/eal/Makefile           |  1 +
 lib/librte_eal/linux/eal/Makefile             |  1 +
 lib/librte_eal/linux/eal/eal_vfio.c           | 16 +++----
 lib/librte_eal/rte_eal_version.map            |  4 ++
 14 files changed, 125 insertions(+), 82 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_mcfg.c

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 1aae56fa9..44e4fa6e2 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -347,14 +347,12 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,
 int rte_fslmc_vfio_dmamap(void)
 {
 	int i = 0, ret;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 
 	/* Lock before parsing and registering callback to memory subsystem */
-	rte_rwlock_read_lock(mem_lock);
+	rte_mcfg_mem_read_lock();
 
 	if (rte_memseg_walk(fslmc_dmamap_seg, &i) < 0) {
-		rte_rwlock_read_unlock(mem_lock);
+		rte_mcfg_mem_read_unlock();
 		return -1;
 	}
 
@@ -378,7 +376,7 @@ int rte_fslmc_vfio_dmamap(void)
 	/* Existing segments have been mapped and memory callback for hotplug
 	 * has been installed.
 	 */
-	rte_rwlock_read_unlock(mem_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return 0;
 }
diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
index 48d458ad4..80827ce75 100644
--- a/drivers/net/mlx4/mlx4_mr.c
+++ b/drivers/net/mlx4/mlx4_mr.c
@@ -593,7 +593,6 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		       uintptr_t addr)
 {
 	struct mlx4_priv *priv = dev->data->dev_private;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	const struct rte_memseg_list *msl;
 	const struct rte_memseg *ms;
 	struct mlx4_mr *mr = NULL;
@@ -696,7 +695,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	 * just single page. If not, go on with the big chunk atomically from
 	 * here.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	data_re = data;
 	if (len > msl->page_sz &&
 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
@@ -714,7 +713,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		 */
 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
 		data.end = data.start + msl->page_sz;
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		mr_free(mr);
 		goto alloc_resources;
 	}
@@ -734,7 +733,7 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		DEBUG("port %u found MR for %p on final lookup, abort",
 		      dev->data->port_id, (void *)addr);
 		rte_rwlock_write_unlock(&priv->mr.rwlock);
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		/*
 		 * Must be unlocked before calling rte_free() because
 		 * mlx4_mr_mem_event_free_cb() can be called inside.
@@ -802,12 +801,12 @@ mlx4_mr_create_primary(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	/* Lookup can't fail. */
 	assert(entry->lkey != UINT32_MAX);
 	rte_rwlock_write_unlock(&priv->mr.rwlock);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return entry->lkey;
 err_mrlock:
 	rte_rwlock_write_unlock(&priv->mr.rwlock);
 err_memlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 err_nolock:
 	/*
 	 * In case of error, as this can be called in a datapath, a warning
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 66e8e874e..872d0591e 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -580,7 +580,6 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_ibv_shared *sh = priv->sh;
 	struct mlx5_dev_config *config = &priv->config;
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	const struct rte_memseg_list *msl;
 	const struct rte_memseg *ms;
 	struct mlx5_mr *mr = NULL;
@@ -684,7 +683,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	 * just single page. If not, go on with the big chunk atomically from
 	 * here.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	data_re = data;
 	if (len > msl->page_sz &&
 	    !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) {
@@ -702,7 +701,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 		 */
 		data.start = RTE_ALIGN_FLOOR(addr, msl->page_sz);
 		data.end = data.start + msl->page_sz;
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		mr_free(mr);
 		goto alloc_resources;
 	}
@@ -722,7 +721,7 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 		DEBUG("port %u found MR for %p on final lookup, abort",
 		      dev->data->port_id, (void *)addr);
 		rte_rwlock_write_unlock(&sh->mr.rwlock);
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		/*
 		 * Must be unlocked before calling rte_free() because
 		 * mlx5_mr_mem_event_free_cb() can be called inside.
@@ -790,12 +789,12 @@ mlx5_mr_create_primary(struct rte_eth_dev *dev, struct mlx5_mr_cache *entry,
 	/* Lookup can't fail. */
 	assert(entry->lkey != UINT32_MAX);
 	rte_rwlock_write_unlock(&sh->mr.rwlock);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return entry->lkey;
 err_mrlock:
 	rte_rwlock_write_unlock(&sh->mr.rwlock);
 err_memlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 err_nolock:
 	/*
 	 * In case of error, as this can be called in a datapath, a warning
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index e743695e4..c3ab9a21d 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -125,7 +125,6 @@ is_vhost_user_by_type(const char *path)
 int
 virtio_user_start_device(struct virtio_user_dev *dev)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	uint64_t features;
 	int ret;
 
@@ -142,7 +141,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 	 * replaced when we get proper supports from the
 	 * memory subsystem in the future.
 	 */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	pthread_mutex_lock(&dev->mutex);
 
 	if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0)
@@ -180,12 +179,12 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 
 	dev->started = true;
 	pthread_mutex_unlock(&dev->mutex);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return 0;
 error:
 	pthread_mutex_unlock(&dev->mutex);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	/* TODO: free resource here or caller to check */
 	return -1;
 }
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 <rte_config.h>
+#include <rte_eal_memconfig.h>
+
+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/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 858d56382..fe22b139b 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -596,13 +596,12 @@ rte_memseg_contig_walk_thread_unsafe(rte_memseg_contig_walk_t func, void *arg)
 int
 rte_memseg_contig_walk(rte_memseg_contig_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_contig_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -638,13 +637,12 @@ rte_memseg_walk_thread_unsafe(rte_memseg_walk_t func, void *arg)
 int
 rte_memseg_walk(rte_memseg_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -671,13 +669,12 @@ rte_memseg_list_walk_thread_unsafe(rte_memseg_list_walk_t func, void *arg)
 int
 rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret = 0;
 
 	/* do not allow allocations/frees/init while we iterate */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_list_walk_thread_unsafe(func, arg);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -727,12 +724,11 @@ rte_memseg_get_fd_thread_unsafe(const struct rte_memseg *ms)
 int
 rte_memseg_get_fd(const struct rte_memseg *ms)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_get_fd_thread_unsafe(ms);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -783,12 +779,11 @@ rte_memseg_get_fd_offset_thread_unsafe(const struct rte_memseg *ms,
 int
 rte_memseg_get_fd_offset(const struct rte_memseg *ms, size_t *offset)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	ret = rte_memseg_get_fd_offset_thread_unsafe(ms, offset);
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -809,7 +804,7 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* make sure the segment doesn't already exist */
 	if (malloc_heap_find_external_seg(va_addr, len) != NULL) {
@@ -838,14 +833,13 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],
 	/* memseg list successfully created - increment next socket ID */
 	mcfg->next_socket_id++;
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
 int
 rte_extmem_unregister(void *va_addr, size_t len)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct rte_memseg_list *msl;
 	int ret = 0;
 
@@ -853,7 +847,7 @@ rte_extmem_unregister(void *va_addr, size_t len)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our segment */
 	msl = malloc_heap_find_external_seg(va_addr, len);
@@ -865,14 +859,13 @@ rte_extmem_unregister(void *va_addr, size_t len)
 
 	ret = malloc_heap_destroy_external_seg(msl);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
 static int
 sync_memory(void *va_addr, size_t len, bool attach)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct rte_memseg_list *msl;
 	int ret = 0;
 
@@ -880,7 +873,7 @@ sync_memory(void *va_addr, size_t len, bool attach)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our segment */
 	msl = malloc_heap_find_external_seg(va_addr, len);
@@ -895,7 +888,7 @@ sync_memory(void *va_addr, size_t len, bool attach)
 		ret = rte_fbarray_detach(&msl->memseg_arr);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
@@ -923,7 +916,7 @@ rte_eal_memory_init(void)
 		return -1;
 
 	/* lock mem hotplug here, to prevent races while we init */
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 
 	if (rte_eal_memseg_init() < 0)
 		goto fail;
@@ -942,6 +935,6 @@ rte_eal_memory_init(void)
 
 	return 0;
 fail:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return -1;
 }
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/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index f9235932e..f1d31de0d 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -485,10 +485,9 @@ try_expand_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,
 		int socket, unsigned int flags, size_t align, size_t bound,
 		bool contig)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	int ret;
 
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		ret = try_expand_heap_primary(heap, pg_sz, elt_size, socket,
@@ -498,7 +497,7 @@ try_expand_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size,
 				flags, align, bound, contig);
 	}
 
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 	return ret;
 }
 
@@ -821,7 +820,6 @@ malloc_heap_free_pages(void *aligned_start, size_t aligned_len)
 int
 malloc_heap_free(struct malloc_elem *elem)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap;
 	void *start, *aligned_start, *end, *aligned_end;
 	size_t len, aligned_len, page_sz;
@@ -935,7 +933,7 @@ malloc_heap_free(struct malloc_elem *elem)
 
 	/* now we can finally free us some pages */
 
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/*
 	 * we allow secondary processes to clear the heap of this allocated
@@ -990,7 +988,7 @@ malloc_heap_free(struct malloc_elem *elem)
 	RTE_LOG(DEBUG, EAL, "Heap on socket %d was shrunk by %zdMB\n",
 		msl->socket_id, aligned_len >> 20ULL);
 
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 free_unlock:
 	rte_spinlock_unlock(&(heap->lock));
 	return ret;
@@ -1344,7 +1342,7 @@ rte_eal_malloc_heap_init(void)
 
 	if (register_mp_requests()) {
 		RTE_LOG(ERR, EAL, "Couldn't register malloc multiprocess actions\n");
-		rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+		rte_mcfg_mem_read_unlock();
 		return -1;
 	}
 
@@ -1352,7 +1350,7 @@ rte_eal_malloc_heap_init(void)
 	 * even come before primary itself is fully initialized, and secondaries
 	 * do not need to initialize the heap.
 	 */
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	/* secondary process does not need to initialize anything */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build
index bafd23207..58b433bc2 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/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index b119ebae3..2cad7beaa 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -223,7 +223,7 @@ rte_malloc_heap_get_socket(const char *name)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	for (idx = 0; idx < RTE_MAX_HEAPS; idx++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[idx];
 
@@ -239,7 +239,7 @@ rte_malloc_heap_get_socket(const char *name)
 		rte_errno = ENOENT;
 		ret = -1;
 	}
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -254,7 +254,7 @@ rte_malloc_heap_socket_is_external(int socket_id)
 	if (socket_id == SOCKET_ID_ANY)
 		return 0;
 
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 	for (idx = 0; idx < RTE_MAX_HEAPS; idx++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[idx];
 
@@ -264,7 +264,7 @@ rte_malloc_heap_socket_is_external(int socket_id)
 			break;
 		}
 	}
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 
 	return ret;
 }
@@ -352,7 +352,6 @@ int
 rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 		rte_iova_t iova_addrs[], unsigned int n_pages, size_t page_sz)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	unsigned int n;
@@ -369,7 +368,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* find our heap */
 	heap = find_named_heap(heap_name);
@@ -398,7 +397,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 	rte_spinlock_unlock(&heap->lock);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -406,7 +405,6 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,
 int
 rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	int ret;
@@ -418,7 +416,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 	/* find our heap */
 	heap = find_named_heap(heap_name);
 	if (heap == NULL) {
@@ -448,7 +446,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 	ret = malloc_heap_destroy_external_seg(msl);
 
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -456,7 +454,6 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
 static int
 sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	struct rte_memseg_list *msl;
 	int ret;
@@ -468,7 +465,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_read_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_lock();
 
 	/* find our heap */
 	heap = find_named_heap(heap_name);
@@ -516,7 +513,7 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
 		}
 	}
 unlock:
-	rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_read_unlock();
 	return ret;
 }
 
@@ -549,7 +546,7 @@ rte_malloc_heap_create(const char *heap_name)
 	/* check if there is space in the heap list, or if heap with this name
 	 * already exists.
 	 */
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	for (i = 0; i < RTE_MAX_HEAPS; i++) {
 		struct malloc_heap *tmp = &mcfg->malloc_heaps[i];
@@ -578,7 +575,7 @@ rte_malloc_heap_create(const char *heap_name)
 	/* we're sure that we can create a new heap, so do it */
 	ret = malloc_heap_create(heap, heap_name);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
@@ -586,7 +583,6 @@ rte_malloc_heap_create(const char *heap_name)
 int
 rte_malloc_heap_destroy(const char *heap_name)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	struct malloc_heap *heap = NULL;
 	int ret;
 
@@ -597,7 +593,7 @@ rte_malloc_heap_destroy(const char *heap_name)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	rte_rwlock_write_lock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_lock();
 
 	/* start from non-socket heaps */
 	heap = find_named_heap(heap_name);
@@ -621,7 +617,7 @@ rte_malloc_heap_destroy(const char *heap_name)
 	if (ret < 0)
 		rte_spinlock_unlock(&heap->lock);
 unlock:
-	rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock);
+	rte_mcfg_mem_write_unlock();
 
 	return ret;
 }
diff --git a/lib/librte_eal/freebsd/eal/Makefile b/lib/librte_eal/freebsd/eal/Makefile
index ca616c480..eb921275e 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 729795a10..dfe8e9a49 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/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index feada64c0..96a03a657 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -635,8 +635,6 @@ int
 rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 		int *vfio_dev_fd, struct vfio_device_info *device_info)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 	struct vfio_group_status group_status = {
 			.argsz = sizeof(group_status)
 	};
@@ -739,7 +737,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 			/* lock memory hotplug before mapping and release it
 			 * after registering callback, to prevent races
 			 */
-			rte_rwlock_read_lock(mem_lock);
+			rte_mcfg_mem_read_lock();
 			if (vfio_cfg == default_vfio_cfg)
 				ret = t->dma_map_func(vfio_container_fd);
 			else
@@ -750,7 +748,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 					dev_addr, errno, strerror(errno));
 				close(vfio_group_fd);
 				rte_vfio_clear_group(vfio_group_fd);
-				rte_rwlock_read_unlock(mem_lock);
+				rte_mcfg_mem_read_unlock();
 				return -1;
 			}
 
@@ -781,7 +779,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 							map->len);
 					rte_spinlock_recursive_unlock(
 							&user_mem_maps->lock);
-					rte_rwlock_read_unlock(mem_lock);
+					rte_mcfg_mem_read_unlock();
 					return -1;
 				}
 			}
@@ -795,7 +793,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
 			else
 				ret = 0;
 			/* unlock memory hotplug */
-			rte_rwlock_read_unlock(mem_lock);
+			rte_mcfg_mem_read_unlock();
 
 			if (ret && rte_errno != ENOTSUP) {
 				RTE_LOG(ERR, EAL, "Could not install memory event callback for VFIO\n");
@@ -862,8 +860,6 @@ int
 rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 		    int vfio_dev_fd)
 {
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock;
 	struct vfio_group_status group_status = {
 			.argsz = sizeof(group_status)
 	};
@@ -876,7 +872,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 	 * VFIO device, because this might be the last device and we might need
 	 * to unregister the callback.
 	 */
-	rte_rwlock_read_lock(mem_lock);
+	rte_mcfg_mem_read_lock();
 
 	/* get group number */
 	ret = rte_vfio_get_group_num(sysfs_base, dev_addr, &iommu_group_num);
@@ -947,7 +943,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
 	ret = 0;
 
 out:
-	rte_rwlock_read_unlock(mem_lock);
+	rte_mcfg_mem_read_unlock();
 	return ret;
 }
 
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index a53a29a35..754060dc9 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;
 	rte_rand;
 	rte_srand;
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v5 2/9] eal: add EAL tailq list lock/unlock API
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 0/9] " Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 1/9] eal: add API to lock/unlock memory hotplug Anatoly Burakov
@ 2019-07-05 17:26       ` Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 3/9] eal: add new API to lock/unlock mempool list Anatoly Burakov
                         ` (6 subsequent siblings)
  9 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 17:26 UTC (permalink / raw)
  To: dev
  Cc: Konstantin Ananyev, David Hunt, Byron Marohn,
	Pablo de Lara Guarch, Jerin Jacob, Yipeng Wang, Sameh Gobriel,
	Bruce Richardson, Ferruh Yigit, Vladimir Medvedkin, Olivier Matz,
	Andrew Rybchenko, Reshma Pattan, Gage Eads, thomas,
	david.marchand, stephen

Currently, locking/unlocking the TAILQ list requires direct
access to the shared memory config. Add an API to do the same,
and search-and-replace all usages.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_acl/rte_acl.c                      | 18 ++++++------
 lib/librte_distributor/rte_distributor.c      |  4 +--
 lib/librte_distributor/rte_distributor_v20.c  |  4 +--
 lib/librte_eal/common/eal_common_mcfg.c       | 28 +++++++++++++++++++
 lib/librte_eal/common/eal_common_tailqs.c     |  4 +--
 lib/librte_eal/common/include/rte_eal.h       |  5 ----
 .../common/include/rte_eal_memconfig.h        | 24 ++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  4 +++
 lib/librte_efd/rte_efd.c                      | 14 +++++-----
 lib/librte_eventdev/rte_event_ring.c          | 16 +++++------
 lib/librte_hash/rte_cuckoo_hash.c             | 16 +++++------
 lib/librte_hash/rte_fbk_hash.c                | 14 +++++-----
 lib/librte_kni/rte_kni.c                      | 16 +++++------
 lib/librte_lpm/rte_lpm.c                      | 24 ++++++++--------
 lib/librte_lpm/rte_lpm6.c                     | 14 +++++-----
 lib/librte_member/rte_member.c                | 16 +++++------
 lib/librte_mempool/rte_mempool.c              |  8 +++---
 lib/librte_reorder/rte_reorder.c              | 14 +++++-----
 lib/librte_ring/rte_ring.c                    | 18 ++++++------
 lib/librte_stack/rte_stack.c                  | 18 ++++++------
 20 files changed, 165 insertions(+), 114 deletions(-)

diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index fd5bd5e4e..7ff11d25f 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -156,13 +156,13 @@ rte_acl_find_existing(const char *name)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, acl_list, next) {
 		ctx = (struct rte_acl_ctx *) te->data;
 		if (strncmp(name, ctx->name, sizeof(ctx->name)) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -182,7 +182,7 @@ rte_acl_free(struct rte_acl_ctx *ctx)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, acl_list, next) {
@@ -190,13 +190,13 @@ rte_acl_free(struct rte_acl_ctx *ctx)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(acl_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(ctx->mem);
 	rte_free(ctx);
@@ -226,7 +226,7 @@ rte_acl_create(const struct rte_acl_param *param)
 	sz = sizeof(*ctx) + param->max_rule_num * param->rule_size;
 
 	/* get EAL TAILQ lock. */
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* if we already have one with that name */
 	TAILQ_FOREACH(te, acl_list, next) {
@@ -268,7 +268,7 @@ rte_acl_create(const struct rte_acl_param *param)
 	}
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return ctx;
 }
 
@@ -377,10 +377,10 @@ rte_acl_list_dump(void)
 
 	acl_list = RTE_TAILQ_CAST(rte_acl_tailq.head, rte_acl_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, acl_list, next) {
 		ctx = (struct rte_acl_ctx *) te->data;
 		rte_acl_dump(ctx);
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 }
diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 208abfb1d..9eb78b330 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -645,9 +645,9 @@ rte_distributor_create_v1705(const char *name,
 					  rte_dist_burst_list);
 
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(dist_burst_list, d, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return d;
 }
diff --git a/lib/librte_distributor/rte_distributor_v20.c b/lib/librte_distributor/rte_distributor_v20.c
index cd5940713..1fc03b971 100644
--- a/lib/librte_distributor/rte_distributor_v20.c
+++ b/lib/librte_distributor/rte_distributor_v20.c
@@ -392,9 +392,9 @@ rte_distributor_create_v20(const char *name,
 	distributor_list = RTE_TAILQ_CAST(rte_distributor_tailq.head,
 					  rte_distributor_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(distributor_list, d, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return d;
 }
diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 985d36cc2..05167e4dc 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -32,3 +32,31 @@ 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);
 }
+
+void
+rte_mcfg_tailq_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->qlock);
+}
+
+void
+rte_mcfg_tailq_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->qlock);
+}
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index ca2a7d32a..dc2c13caa 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -58,7 +58,7 @@ rte_dump_tailq(FILE *f)
 
 	mcfg = rte_eal_get_configuration()->mem_config;
 
-	rte_rwlock_read_lock(&mcfg->qlock);
+	rte_mcfg_tailq_read_lock();
 	for (i = 0; i < RTE_MAX_TAILQ; i++) {
 		const struct rte_tailq_head *tailq = &mcfg->tailq_head[i];
 		const struct rte_tailq_entry_head *head = &tailq->tailq_head;
@@ -66,7 +66,7 @@ rte_dump_tailq(FILE *f)
 		fprintf(f, "Tailq %u: qname:<%s>, tqh_first:%p, tqh_last:%p\n",
 			i, tailq->name, head->tqh_first, head->tqh_last);
 	}
-	rte_rwlock_read_unlock(&mcfg->qlock);
+	rte_mcfg_tailq_read_unlock();
 }
 
 static struct rte_tailq_head *
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index bf0c74e07..28cbf2dde 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -446,11 +446,6 @@ typedef void	(*rte_usage_hook_t)(const char * prgname);
 rte_usage_hook_t
 rte_set_application_usage_hook(rte_usage_hook_t usage_func);
 
-/**
- * macro to get the lock of tailq in mem_config
- */
-#define RTE_EAL_TAILQ_RWLOCK         (&rte_eal_get_configuration()->mem_config->qlock)
-
 /**
  * macro to get the multiple lock of mempool shared by multiple-instance
  */
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index a554518ef..240fa150b 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -124,6 +124,30 @@ rte_mcfg_mem_write_lock(void);
 void
 rte_mcfg_mem_write_unlock(void);
 
+/**
+ * Lock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_mcfg_tailq_read_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for shared access.
+ */
+void
+rte_mcfg_tailq_read_unlock(void);
+
+/**
+ * Lock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_mcfg_tailq_write_lock(void);
+
+/**
+ * Unlock the internal EAL TAILQ list for exclusive access.
+ */
+void
+rte_mcfg_tailq_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 754060dc9..d78a3a8b9 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -296,6 +296,10 @@ DPDK_19.08 {
 	rte_mcfg_mem_read_unlock;
 	rte_mcfg_mem_write_lock;
 	rte_mcfg_mem_write_unlock;
+	rte_mcfg_tailq_read_lock;
+	rte_mcfg_tailq_read_unlock;
+	rte_mcfg_tailq_write_lock;
+	rte_mcfg_tailq_write_unlock;
 	rte_rand;
 	rte_srand;
 
diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index 14e493bc3..b808ce99f 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -532,7 +532,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	num_chunks_shift = rte_bsf32(num_chunks);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/*
 	 * Guarantee there's no existing: this is normally already checked
@@ -685,7 +685,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 
 	te->data = (void *) table;
 	TAILQ_INSERT_TAIL(efd_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	snprintf(ring_name, sizeof(ring_name), "HT_%s", table->name);
 	/* Create ring (Dummy slot index is not enqueued) */
@@ -705,7 +705,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	return table;
 
 error_unlock_exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_efd_free(table);
 
 	return NULL;
@@ -720,7 +720,7 @@ rte_efd_find_existing(const char *name)
 
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, efd_list, next)
 	{
@@ -728,7 +728,7 @@ rte_efd_find_existing(const char *name)
 		if (strncmp(name, table->name, RTE_EFD_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -751,7 +751,7 @@ rte_efd_free(struct rte_efd_table *table)
 		rte_free(table->chunks[socket_id]);
 
 	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH_SAFE(te, efd_list, next, temp) {
 		if (te->data == (void *) table) {
@@ -761,7 +761,7 @@ rte_efd_free(struct rte_efd_table *table)
 		}
 	}
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_ring_free(table->free_slots);
 	rte_free(table->offline_chunks);
 	rte_free(table->keys);
diff --git a/lib/librte_eventdev/rte_event_ring.c b/lib/librte_eventdev/rte_event_ring.c
index 16d02a953..50190de01 100644
--- a/lib/librte_eventdev/rte_event_ring.c
+++ b/lib/librte_eventdev/rte_event_ring.c
@@ -72,7 +72,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/*
 	 * reserve a memory zone for this ring. If we can't get rte_config or
@@ -89,7 +89,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 			if (rte_memzone_free(mz) != 0)
 				RTE_LOG(ERR, RING, "Cannot free memzone\n");
 			rte_free(te);
-			rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+			rte_mcfg_tailq_write_unlock();
 			return NULL;
 		}
 
@@ -102,7 +102,7 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return r;
 }
@@ -118,7 +118,7 @@ rte_event_ring_lookup(const char *name)
 	ring_list = RTE_TAILQ_CAST(rte_event_ring_tailq.head,
 			rte_event_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		r = (struct rte_event_ring *) te->data;
@@ -126,7 +126,7 @@ rte_event_ring_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -163,7 +163,7 @@ rte_event_ring_free(struct rte_event_ring *r)
 
 	ring_list = RTE_TAILQ_CAST(rte_event_ring_tailq.head,
 			rte_event_ring_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, ring_list, next) {
@@ -172,13 +172,13 @@ rte_event_ring_free(struct rte_event_ring *r)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(ring_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 }
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 51198b477..47cd0da5b 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -52,13 +52,13 @@ rte_hash_find_existing(const char *name)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, hash_list, next) {
 		h = (struct rte_hash *) te->data;
 		if (strncmp(name, h->name, RTE_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -239,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	snprintf(hash_name, sizeof(hash_name), "HT_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing: this is normally already checked
 	 * by ring creation above */
@@ -437,11 +437,11 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	te->data = (void *) h;
 	TAILQ_INSERT_TAIL(hash_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return h;
 err_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 err:
 	rte_ring_free(r);
 	rte_ring_free(r_ext);
@@ -466,7 +466,7 @@ rte_hash_free(struct rte_hash *h)
 
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, hash_list, next) {
@@ -475,13 +475,13 @@ rte_hash_free(struct rte_hash *h)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	if (h->use_local_cache)
 		rte_free(h->local_free_slots);
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index 9360f7981..db118c930 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -50,13 +50,13 @@ rte_fbk_hash_find_existing(const char *name)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
 		h = (struct rte_fbk_hash_table *) te->data;
 		if (strncmp(name, h->name, RTE_FBK_HASH_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 	if (te == NULL) {
 		rte_errno = ENOENT;
 		return NULL;
@@ -103,7 +103,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 
 	snprintf(hash_name, sizeof(hash_name), "FBK_%s", params->name);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -165,7 +165,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
 	TAILQ_INSERT_TAIL(fbk_hash_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return ht;
 }
@@ -188,7 +188,7 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	fbk_hash_list = RTE_TAILQ_CAST(rte_fbk_hash_tailq.head,
 				       rte_fbk_hash_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, fbk_hash_list, next) {
@@ -197,13 +197,13 @@ rte_fbk_hash_free(struct rte_fbk_hash_table *ht)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(fbk_hash_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(ht);
 	rte_free(te);
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 00104a35d..309e45918 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -214,7 +214,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	kni = __rte_kni_get(conf->name);
 	if (kni != NULL) {
@@ -304,7 +304,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 	TAILQ_INSERT_TAIL(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	/* Allocate mbufs and then put them into alloc_q */
 	kni_allocate_mbufs(kni);
@@ -318,7 +318,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
 kni_fail:
 	rte_free(te);
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return NULL;
 }
@@ -381,7 +381,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, kni_list, next) {
 		if (te->data == kni)
@@ -399,7 +399,7 @@ rte_kni_release(struct rte_kni *kni)
 
 	TAILQ_REMOVE(kni_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	/* mbufs in all fifo should be released, except request/response */
 
@@ -423,7 +423,7 @@ rte_kni_release(struct rte_kni *kni)
 	return 0;
 
 unlock:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return -1;
 }
@@ -640,11 +640,11 @@ rte_kni_get(const char *name)
 	if (name == NULL || name[0] == '\0')
 		return NULL;
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	kni = __rte_kni_get(name);
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	return kni;
 }
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index 6b7b28a2e..b91f74216 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -97,13 +97,13 @@ rte_lpm_find_existing_v20(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -123,13 +123,13 @@ rte_lpm_find_existing_v1604(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = te->data;
 		if (strncmp(name, l->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -170,7 +170,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	/* Determine the amount of memory to allocate. */
 	mem_size = sizeof(*lpm) + (sizeof(lpm->rules_tbl[0]) * max_rules);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -212,7 +212,7 @@ rte_lpm_create_v20(const char *name, int socket_id, int max_rules,
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return lpm;
 }
@@ -247,7 +247,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	tbl8s_size = (sizeof(struct rte_lpm_tbl_entry) *
 			RTE_LPM_TBL8_GROUP_NUM_ENTRIES * config->number_tbl8s);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -315,7 +315,7 @@ rte_lpm_create_v1604(const char *name, int socket_id,
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return lpm;
 }
@@ -339,7 +339,7 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -349,7 +349,7 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm);
 	rte_free(te);
@@ -368,7 +368,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -378,7 +378,7 @@ rte_lpm_free_v1604(struct rte_lpm *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm->tbl8);
 	rte_free(lpm->rules_tbl);
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index a91803113..5af74a539 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -316,7 +316,7 @@ rte_lpm6_create(const char *name, int socket_id,
 	mem_size = sizeof(*lpm) + (sizeof(lpm->tbl8[0]) *
 			RTE_LPM6_TBL8_GROUP_NUM_ENTRIES * config->number_tbl8s);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* Guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -363,11 +363,11 @@ rte_lpm6_create(const char *name, int socket_id,
 	te->data = (void *) lpm;
 
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return lpm;
 
 fail:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 fail_wo_unlock:
 	rte_free(tbl8_hdrs);
@@ -389,13 +389,13 @@ rte_lpm6_find_existing(const char *name)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, lpm_list, next) {
 		l = (struct rte_lpm6 *) te->data;
 		if (strncmp(name, l->name, RTE_LPM6_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -420,7 +420,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
 
 	lpm_list = RTE_TAILQ_CAST(rte_lpm6_tailq.head, rte_lpm6_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
@@ -431,7 +431,7 @@ rte_lpm6_free(struct rte_lpm6 *lpm)
 	if (te != NULL)
 		TAILQ_REMOVE(lpm_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(lpm->tbl8_hdrs);
 	rte_free(lpm->tbl8_pool);
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index fd228f4ba..efed28dd9 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -32,13 +32,13 @@ rte_member_find_existing(const char *name)
 
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, member_list, next) {
 		setsum = (struct rte_member_setsum *) te->data;
 		if (strncmp(name, setsum->name, RTE_MEMBER_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -56,17 +56,17 @@ rte_member_free(struct rte_member_setsum *setsum)
 	if (setsum == NULL)
 		return;
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_FOREACH(te, member_list, next) {
 		if (te->data == (void *)setsum)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 	TAILQ_REMOVE(member_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	switch (setsum->type) {
 	case RTE_MEMBER_TYPE_HT:
@@ -105,7 +105,7 @@ rte_member_create(const struct rte_member_parameters *params)
 
 	member_list = RTE_TAILQ_CAST(rte_member_tailq.head, rte_member_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	TAILQ_FOREACH(te, member_list, next) {
 		setsum = te->data;
@@ -159,13 +159,13 @@ rte_member_create(const struct rte_member_parameters *params)
 
 	te->data = (void *)setsum;
 	TAILQ_INSERT_TAIL(member_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return setsum;
 
 error_unlock_exit:
 	rte_free(te);
 	rte_free(setsum);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return NULL;
 }
 
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 69bd2a65c..238287a01 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -711,7 +711,7 @@ rte_mempool_free(struct rte_mempool *mp)
 		return;
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, mempool_list, next) {
 		if (te->data == (void *)mp)
@@ -722,7 +722,7 @@ rte_mempool_free(struct rte_mempool *mp)
 		TAILQ_REMOVE(mempool_list, te, next);
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_mempool_free_memchunks(mp);
 	rte_mempool_ops_free(mp);
@@ -898,9 +898,9 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 
 	te->data = mp;
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(mempool_list, te, next);
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
 
 	return mp;
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index 3a4a1b0a0..ae6e3f578 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -119,7 +119,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, reorder_list, next) {
@@ -152,7 +152,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
 	}
 
 exit:
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 	return b;
 }
 
@@ -193,7 +193,7 @@ rte_reorder_free(struct rte_reorder_buffer *b)
 
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, reorder_list, next) {
@@ -201,13 +201,13 @@ rte_reorder_free(struct rte_reorder_buffer *b)
 			break;
 	}
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(reorder_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_reorder_free_mbufs(b);
 
@@ -229,13 +229,13 @@ rte_reorder_find_existing(const char *name)
 
 	reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 	TAILQ_FOREACH(te, reorder_list, next) {
 		b = (struct rte_reorder_buffer *) te->data;
 		if (strncmp(name, b->name, RTE_REORDER_NAMESIZE) == 0)
 			break;
 	}
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index b89ecf999..9ea26a631 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -147,7 +147,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* reserve a memory zone for this ring. If we can't get rte_config or
 	 * we are secondary process, the memzone_reserve function will set
@@ -169,7 +169,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
 		RTE_LOG(ERR, RING, "Cannot reserve memory\n");
 		rte_free(te);
 	}
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return r;
 }
@@ -200,7 +200,7 @@ rte_ring_free(struct rte_ring *r)
 	}
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, ring_list, next) {
@@ -209,13 +209,13 @@ rte_ring_free(struct rte_ring *r)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(ring_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 }
@@ -245,13 +245,13 @@ rte_ring_list_dump(FILE *f)
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		rte_ring_dump(f, (struct rte_ring *) te->data);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 }
 
 /* search a ring from its name */
@@ -264,7 +264,7 @@ rte_ring_lookup(const char *name)
 
 	ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, ring_list, next) {
 		r = (struct rte_ring *) te->data;
@@ -272,7 +272,7 @@ rte_ring_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index 60f63a65b..2cc7e8e16 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -84,13 +84,13 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	mz = rte_memzone_reserve_aligned(mz_name, sz, socket_id,
 					 0, __alignof__(*s));
 	if (mz == NULL) {
 		STACK_LOG_ERR("Cannot reserve stack memzone!\n");
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		rte_free(te);
 		return NULL;
 	}
@@ -102,7 +102,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 	/* Store the name for later lookups */
 	ret = strlcpy(s->name, name, sizeof(s->name));
 	if (ret < 0 || ret >= (int)sizeof(s->name)) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 
 		rte_errno = ENAMETOOLONG;
 		rte_free(te);
@@ -120,7 +120,7 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
 
 	TAILQ_INSERT_TAIL(stack_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	return s;
 }
@@ -135,7 +135,7 @@ rte_stack_free(struct rte_stack *s)
 		return;
 
 	stack_list = RTE_TAILQ_CAST(rte_stack_tailq.head, rte_stack_list);
-	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_lock();
 
 	/* find out tailq entry */
 	TAILQ_FOREACH(te, stack_list, next) {
@@ -144,13 +144,13 @@ rte_stack_free(struct rte_stack *s)
 	}
 
 	if (te == NULL) {
-		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		rte_mcfg_tailq_write_unlock();
 		return;
 	}
 
 	TAILQ_REMOVE(stack_list, te, next);
 
-	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_write_unlock();
 
 	rte_free(te);
 
@@ -171,7 +171,7 @@ rte_stack_lookup(const char *name)
 
 	stack_list = RTE_TAILQ_CAST(rte_stack_tailq.head, rte_stack_list);
 
-	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_lock();
 
 	TAILQ_FOREACH(te, stack_list, next) {
 		r = (struct rte_stack *) te->data;
@@ -179,7 +179,7 @@ rte_stack_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+	rte_mcfg_tailq_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v5 3/9] eal: add new API to lock/unlock mempool list
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
                         ` (2 preceding siblings ...)
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 2/9] eal: add EAL tailq list lock/unlock API Anatoly Burakov
@ 2019-07-05 17:26       ` Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 4/9] eal: hide shared memory config Anatoly Burakov
                         ` (5 subsequent siblings)
  9 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 17:26 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, Andrew Rybchenko, thomas, david.marchand, stephen

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, and search-and-replace all usages.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eal/common/eal_common_mcfg.c       | 28 +++++++++++++++++++
 lib/librte_eal/common/include/rte_eal.h       |  5 ----
 .../common/include/rte_eal_memconfig.h        | 24 ++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  4 +++
 lib/librte_mempool/rte_mempool.c              | 18 ++++++------
 5 files changed, 65 insertions(+), 14 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 05167e4dc..ba2bc37b7 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -60,3 +60,31 @@ rte_mcfg_tailq_write_unlock(void)
 	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	rte_rwlock_write_unlock(&mcfg->qlock);
 }
+
+void
+rte_mcfg_mempool_read_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_lock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_read_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_read_unlock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_write_lock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_lock(&mcfg->mplock);
+}
+
+void
+rte_mcfg_mempool_write_unlock(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+	rte_rwlock_write_unlock(&mcfg->mplock);
+}
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index 28cbf2dde..34245b053 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -446,11 +446,6 @@ typedef void	(*rte_usage_hook_t)(const char * prgname);
 rte_usage_hook_t
 rte_set_application_usage_hook(rte_usage_hook_t usage_func);
 
-/**
- * macro to get the multiple lock of mempool shared by multiple-instance
- */
-#define RTE_EAL_MEMPOOL_RWLOCK            (&rte_eal_get_configuration()->mem_config->mplock)
-
 /**
  * Whether EAL is using huge pages (disabled by --no-huge option).
  * The no-huge mode cannot be used with UIO poll-mode drivers like igb/ixgbe.
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index 240fa150b..58dcbb96d 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_mcfg_tailq_write_lock(void);
 void
 rte_mcfg_tailq_write_unlock(void);
 
+/**
+ * Lock the internal EAL Mempool list for shared access.
+ */
+void
+rte_mcfg_mempool_read_lock(void);
+
+/**
+ * Unlock the internal EAL Mempool list for shared access.
+ */
+void
+rte_mcfg_mempool_read_unlock(void);
+
+/**
+ * Lock the internal EAL Mempool list for exclusive access.
+ */
+void
+rte_mcfg_mempool_write_lock(void);
+
+/**
+ * Unlock the internal EAL Mempool list for exclusive access.
+ */
+void
+rte_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 d78a3a8b9..cc4ef04a0 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -296,6 +296,10 @@ DPDK_19.08 {
 	rte_mcfg_mem_read_unlock;
 	rte_mcfg_mem_write_lock;
 	rte_mcfg_mem_write_unlock;
+	rte_mcfg_mempool_read_lock;
+	rte_mcfg_mempool_read_unlock;
+	rte_mcfg_mempool_write_lock;
+	rte_mcfg_mempool_write_unlock;
 	rte_mcfg_tailq_read_lock;
 	rte_mcfg_tailq_read_unlock;
 	rte_mcfg_tailq_write_lock;
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 238287a01..5c688d456 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -830,7 +830,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 		return NULL;
 	}
 
-	rte_rwlock_write_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_lock();
 
 	/*
 	 * reserve a memory zone for this mempool: private data is
@@ -901,12 +901,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 	rte_mcfg_tailq_write_lock();
 	TAILQ_INSERT_TAIL(mempool_list, te, next);
 	rte_mcfg_tailq_write_unlock();
-	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_unlock();
 
 	return mp;
 
 exit_unlock:
-	rte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_write_unlock();
 	rte_free(te);
 	rte_mempool_free(mp);
 	return NULL;
@@ -1268,14 +1268,14 @@ rte_mempool_list_dump(FILE *f)
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH(te, mempool_list, next) {
 		mp = (struct rte_mempool *) te->data;
 		rte_mempool_dump(f, mp);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 }
 
 /* search a mempool from its name */
@@ -1288,7 +1288,7 @@ rte_mempool_lookup(const char *name)
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH(te, mempool_list, next) {
 		mp = (struct rte_mempool *) te->data;
@@ -1296,7 +1296,7 @@ rte_mempool_lookup(const char *name)
 			break;
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 
 	if (te == NULL) {
 		rte_errno = ENOENT;
@@ -1315,11 +1315,11 @@ void rte_mempool_walk(void (*func)(struct rte_mempool *, void *),
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
-	rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_lock();
 
 	TAILQ_FOREACH_SAFE(te, mempool_list, next, tmp_te) {
 		(*func)((struct rte_mempool *) te->data, arg);
 	}
 
-	rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK);
+	rte_mcfg_mempool_read_unlock();
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v5 4/9] eal: hide shared memory config
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
                         ` (3 preceding siblings ...)
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 3/9] eal: add new API to lock/unlock mempool list Anatoly Burakov
@ 2019-07-05 17:26       ` Anatoly Burakov
  2019-07-05 19:08         ` Thomas Monjalon
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 5/9] eal: remove packed attribute from mcfg structure Anatoly Burakov
                         ` (4 subsequent siblings)
  9 siblings, 1 reply; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 17:26 UTC (permalink / raw)
  To: dev
  Cc: Neil Horman, John McNamara, Marko Kovacevic, Konstantin Ananyev,
	David Hunt, Bruce Richardson, Byron Marohn, Pablo de Lara Guarch,
	Yipeng Wang, Sameh Gobriel, Vladimir Medvedkin, Olivier Matz,
	Andrew Rybchenko, Honnappa Nagarahalli, Reshma Pattan, thomas,
	david.marchand, stephen

Now that everything that has ever accessed the shared memory
config is doing so through the public API's, we can make it
internal. Since we're removing quite a few headers from
rte_eal_memconfig.h, we need to add them back in places
where this header is used.

This bumps the ABI, so also change all build files and make
update documentation.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 app/test/test_fbarray.c                       |  1 +
 app/test/test_memzone.c                       |  1 +
 app/test/test_tailq.c                         |  1 +
 doc/guides/rel_notes/deprecation.rst          |  3 -
 doc/guides/rel_notes/release_19_08.rst        |  8 +-
 drivers/bus/pci/linux/pci_vfio.c              |  1 +
 lib/librte_acl/rte_acl.c                      |  2 +
 lib/librte_distributor/rte_distributor.c      |  1 +
 lib/librte_distributor/rte_distributor_v20.c  |  1 +
 lib/librte_eal/common/eal_common_mcfg.c       |  2 +
 lib/librte_eal/common/eal_common_memory.c     |  1 +
 lib/librte_eal/common/eal_common_memzone.c    |  1 +
 lib/librte_eal/common/eal_common_tailqs.c     |  1 +
 lib/librte_eal/common/eal_memcfg.h            | 80 ++++++++++++++++
 .../common/include/rte_eal_memconfig.h        | 95 +------------------
 lib/librte_eal/common/include/rte_fbarray.h   |  1 -
 lib/librte_eal/common/include/rte_memory.h    | 24 ++++-
 lib/librte_eal/common/malloc_heap.c           |  2 +
 lib/librte_eal/common/malloc_mp.c             |  1 +
 lib/librte_eal/common/rte_malloc.c            |  1 +
 lib/librte_eal/freebsd/eal/Makefile           |  2 +-
 lib/librte_eal/freebsd/eal/eal_memory.c       |  1 +
 lib/librte_eal/linux/eal/Makefile             |  2 +-
 lib/librte_eal/linux/eal/eal.c                |  1 +
 lib/librte_eal/linux/eal/eal_memalloc.c       |  1 +
 lib/librte_eal/linux/eal/eal_memory.c         |  1 +
 lib/librte_eal/linux/eal/eal_vfio.c           |  1 +
 lib/librte_eal/meson.build                    |  2 +-
 lib/librte_efd/rte_efd.c                      |  1 +
 lib/librte_hash/rte_cuckoo_hash.c             |  1 +
 lib/librte_hash/rte_fbk_hash.c                |  1 +
 lib/librte_lpm/rte_lpm.c                      |  1 +
 lib/librte_lpm/rte_lpm6.c                     |  1 +
 lib/librte_member/rte_member.c                |  1 +
 lib/librte_mempool/rte_mempool.c              |  1 +
 lib/librte_rcu/rte_rcu_qsbr.h                 |  1 +
 lib/librte_reorder/rte_reorder.c              |  1 +
 lib/librte_ring/rte_ring.c                    |  1 +
 38 files changed, 148 insertions(+), 101 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_memcfg.h

diff --git a/app/test/test_fbarray.c b/app/test/test_fbarray.c
index d2b041887..a691bf445 100644
--- a/app/test/test_fbarray.c
+++ b/app/test/test_fbarray.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <limits.h>
diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index 9fe465e62..7501b63c5 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -19,6 +19,7 @@
 #include <rte_errno.h>
 #include <rte_malloc.h>
 #include "../../lib/librte_eal/common/malloc_elem.h"
+#include "../../lib/librte_eal/common/eal_memcfg.h"
 
 #include "test.h"
 
diff --git a/app/test/test_tailq.c b/app/test/test_tailq.c
index a4ecea2d8..7c9b69fdb 100644
--- a/app/test/test_tailq.c
+++ b/app/test/test_tailq.c
@@ -12,6 +12,7 @@
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
 #include <rte_string_fns.h>
+#include <rte_tailq.h>
 
 #include "test.h"
 
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index e2721fad6..583217da8 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -23,9 +23,6 @@ Deprecation Notices
 * eal: The function ``rte_eal_remote_launch`` will return new error codes
   after read or write error on the pipe, instead of calling ``rte_panic``.
 
-* eal: the ``rte_mem_config`` struct will be made private to remove it from the
-  externally visible ABI and allow it to be updated in the future.
-
 * eal: both declaring and identifying devices will be streamlined in v18.11.
   New functions will appear to query a specific port from buses, classes of
   device and device drivers. Device declaration will be made coherent with the
diff --git a/doc/guides/rel_notes/release_19_08.rst b/doc/guides/rel_notes/release_19_08.rst
index 21934bf01..cc6dfa33f 100644
--- a/doc/guides/rel_notes/release_19_08.rst
+++ b/doc/guides/rel_notes/release_19_08.rst
@@ -172,6 +172,10 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+* The ``rte_mem_config`` structure has been made private. The new accessor
+  ``rte_mcfg_*`` functions were introduced to provide replacement for direct
+  access to the shared mem config.
+
 * The network structures, definitions and functions have
   been prefixed by ``rte_`` to resolve conflicts with libc headers.
 
@@ -201,6 +205,8 @@ ABI Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+* The ``rte_mem_config`` structure has been made private.
+
 * eventdev: Event based Rx adapter callback
 
   The mbuf pointer array in the event eth Rx adapter callback
@@ -246,7 +252,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_compressdev.so.1
      librte_cryptodev.so.7
      librte_distributor.so.1
-     librte_eal.so.10
+   + librte_eal.so.11
      librte_efd.so.1
      librte_ethdev.so.12
    + librte_eventdev.so.7
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index ebf6ccd3c..1ceb1c07b 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -20,6 +20,7 @@
 #include <rte_eal.h>
 #include <rte_bus.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "eal_filesystem.h"
 
diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index 7ff11d25f..bd7247cc3 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -4,6 +4,8 @@
 
 #include <rte_string_fns.h>
 #include <rte_acl.h>
+#include <rte_tailq.h>
+
 #include "acl.h"
 
 TAILQ_HEAD(rte_acl_list, rte_tailq_entry);
diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c
index 9eb78b330..0a3213bbf 100644
--- a/lib/librte_distributor/rte_distributor.c
+++ b/lib/librte_distributor/rte_distributor.c
@@ -14,6 +14,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_private.h"
 #include "rte_distributor.h"
diff --git a/lib/librte_distributor/rte_distributor_v20.c b/lib/librte_distributor/rte_distributor_v20.c
index 1fc03b971..cdc0969a8 100644
--- a/lib/librte_distributor/rte_distributor_v20.c
+++ b/lib/librte_distributor/rte_distributor_v20.c
@@ -13,6 +13,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_v20.h"
 #include "rte_distributor_private.h"
diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index ba2bc37b7..337890a61 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -5,6 +5,8 @@
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
 
+#include "eal_memcfg.h"
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index fe22b139b..19ea47570 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -24,6 +24,7 @@
 #include "eal_memalloc.h"
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
+#include "eal_memcfg.h"
 #include "malloc_heap.h"
 
 /*
diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
index 521ad7ca1..ef6c909cb 100644
--- a/lib/librte_eal/common/eal_common_memzone.c
+++ b/lib/librte_eal/common/eal_common_memzone.c
@@ -24,6 +24,7 @@
 #include "malloc_heap.h"
 #include "malloc_elem.h"
 #include "eal_private.h"
+#include "eal_memcfg.h"
 
 static inline const struct rte_memzone *
 memzone_lookup_thread_unsafe(const char *name)
diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index dc2c13caa..ead06897b 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -23,6 +23,7 @@
 #include <rte_debug.h>
 
 #include "eal_private.h"
+#include "eal_memcfg.h"
 
 TAILQ_HEAD(rte_tailq_elem_head, rte_tailq_elem);
 /* local tailq list */
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
new file mode 100644
index 000000000..74f6159c6
--- /dev/null
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef EAL_MEMCFG_H
+#define EAL_MEMCFG_H
+
+#include <rte_config.h>
+#include <rte_eal_memconfig.h>
+#include <rte_malloc_heap.h>
+#include <rte_memory.h>
+#include <rte_memzone.h>
+#include <rte_pause.h>
+#include <rte_rwlock.h>
+#include <rte_tailq.h>
+
+/**
+ * Memory configuration shared across multiple processes.
+ */
+struct rte_mem_config {
+	volatile uint32_t magic;   /**< Magic number - sanity check. */
+
+	/* memory topology */
+	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
+	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
+
+	/**
+	 * current lock nest order
+	 *  - qlock->mlock (ring/hash/lpm)
+	 *  - mplock->qlock->mlock (mempool)
+	 * Notice:
+	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
+	 */
+	rte_rwlock_t mlock;   /**< used by memzones for thread safety. */
+	rte_rwlock_t qlock;   /**< used by tailqs for thread safety. */
+	rte_rwlock_t mplock;  /**< used by mempool library for thread safety. */
+
+	rte_rwlock_t memory_hotplug_lock;
+	/**< Indicates whether memory hotplug request is in progress. */
+
+	/* memory segments and zones */
+	struct rte_fbarray memzones; /**< Memzone descriptors. */
+
+	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
+	/**< List of dynamic arrays holding memsegs */
+
+	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ];
+	/**< Tailqs for objects */
+
+	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
+	/**< DPDK malloc heaps */
+
+	int next_socket_id; /**< Next socket ID for external malloc heap */
+
+	/* rte_mem_config has to be mapped at the exact same address in all
+	 * processes, so we need to store it.
+	 */
+	uint64_t mem_cfg_addr; /**< Address of this structure in memory. */
+
+	/* Primary and secondary processes cannot run with different legacy or
+	 * single file segments options, so to avoid having to specify these
+	 * options to all processes, store them in shared config and update the
+	 * internal config at init time.
+	 */
+	uint32_t legacy_mem; /**< stored legacy mem parameter. */
+	uint32_t single_file_segments;
+	/**< stored single file segments parameter. */
+
+	uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
+} __attribute__((packed));
+
+static inline void
+rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
+{
+	/* wait until shared mem_config finish initialising */
+	while (mcfg->magic != RTE_MAGIC)
+		rte_pause();
+}
+
+#endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index 58dcbb96d..dc61a6fed 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -5,101 +5,16 @@
 #ifndef _RTE_EAL_MEMCONFIG_H_
 #define _RTE_EAL_MEMCONFIG_H_
 
-#include <rte_config.h>
-#include <rte_tailq.h>
-#include <rte_memory.h>
-#include <rte_memzone.h>
-#include <rte_malloc_heap.h>
-#include <rte_rwlock.h>
-#include <rte_pause.h>
-#include <rte_fbarray.h>
+/**
+ * @file
+ *
+ * This API allows access to EAL shared memory configuration through an API.
+ */
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/**
- * memseg list is a special case as we need to store a bunch of other data
- * together with the array itself.
- */
-struct rte_memseg_list {
-	RTE_STD_C11
-	union {
-		void *base_va;
-		/**< Base virtual address for this memseg list. */
-		uint64_t addr_64;
-		/**< Makes sure addr is always 64-bits */
-	};
-	uint64_t page_sz; /**< Page size for all memsegs in this list. */
-	int socket_id; /**< Socket ID for all memsegs in this list. */
-	volatile uint32_t version; /**< version number for multiprocess sync. */
-	size_t len; /**< Length of memory area covered by this memseg list. */
-	unsigned int external; /**< 1 if this list points to external memory */
-	struct rte_fbarray memseg_arr;
-};
-
-/**
- * the structure for the memory configuration for the RTE.
- * Used by the rte_config structure. It is separated out, as for multi-process
- * support, the memory details should be shared across instances
- */
-struct rte_mem_config {
-	volatile uint32_t magic;   /**< Magic number - Sanity check. */
-
-	/* memory topology */
-	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
-	uint32_t nrank;       /**< Number of ranks (0 if unknown). */
-
-	/**
-	 * current lock nest order
-	 *  - qlock->mlock (ring/hash/lpm)
-	 *  - mplock->qlock->mlock (mempool)
-	 * Notice:
-	 *  *ALWAYS* obtain qlock first if having to obtain both qlock and mlock
-	 */
-	rte_rwlock_t mlock;   /**< only used by memzone LIB for thread-safe. */
-	rte_rwlock_t qlock;   /**< used for tailq operation for thread safe. */
-	rte_rwlock_t mplock;  /**< only used by mempool LIB for thread-safe. */
-
-	rte_rwlock_t memory_hotplug_lock;
-	/**< indicates whether memory hotplug request is in progress. */
-
-	/* memory segments and zones */
-	struct rte_fbarray memzones; /**< Memzone descriptors. */
-
-	struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS];
-	/**< list of dynamic arrays holding memsegs */
-
-	struct rte_tailq_head tailq_head[RTE_MAX_TAILQ]; /**< Tailqs for objects */
-
-	/* Heaps of Malloc */
-	struct malloc_heap malloc_heaps[RTE_MAX_HEAPS];
-
-	/* next socket ID for external malloc heap */
-	int next_socket_id;
-
-	/* address of mem_config in primary process. used to map shared config into
-	 * exact same address the primary process maps it.
-	 */
-	uint64_t mem_cfg_addr;
-
-	/* legacy mem and single file segments options are shared */
-	uint32_t legacy_mem;
-	uint32_t single_file_segments;
-
-	/* keeps the more restricted dma mask */
-	uint8_t dma_maskbits;
-} __attribute__((__packed__));
-
-
-inline static void
-rte_eal_mcfg_wait_complete(struct rte_mem_config* mcfg)
-{
-	/* wait until shared mem_config finish initialising */
-	while(mcfg->magic != RTE_MAGIC)
-		rte_pause();
-}
-
 /**
  * Lock the internal EAL shared memory configuration for shared access.
  */
diff --git a/lib/librte_eal/common/include/rte_fbarray.h b/lib/librte_eal/common/include/rte_fbarray.h
index d0af2d8c7..6dccdbec9 100644
--- a/lib/librte_eal/common/include/rte_fbarray.h
+++ b/lib/librte_eal/common/include/rte_fbarray.h
@@ -34,7 +34,6 @@
 extern "C" {
 #endif
 
-#include <stdbool.h>
 #include <stdio.h>
 
 #include <rte_compat.h>
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 44cbe6fd2..ca34a10c3 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -22,9 +22,7 @@ extern "C" {
 #include <rte_common.h>
 #include <rte_compat.h>
 #include <rte_config.h>
-
-/* forward declaration for pointers */
-struct rte_memseg_list;
+#include <rte_fbarray.h>
 
 __extension__
 enum rte_page_sizes {
@@ -104,6 +102,26 @@ struct rte_memseg {
 	uint32_t flags;             /**< Memseg-specific flags */
 } __rte_packed;
 
+/**
+ * memseg list is a special case as we need to store a bunch of other data
+ * together with the array itself.
+ */
+struct rte_memseg_list {
+	RTE_STD_C11
+	union {
+		void *base_va;
+		/**< Base virtual address for this memseg list. */
+		uint64_t addr_64;
+		/**< Makes sure addr is always 64-bits */
+	};
+	uint64_t page_sz; /**< Page size for all memsegs in this list. */
+	int socket_id; /**< Socket ID for all memsegs in this list. */
+	volatile uint32_t version; /**< version number for multiprocess sync. */
+	size_t len; /**< Length of memory area covered by this memseg list. */
+	unsigned int external; /**< 1 if this list points to external memory */
+	struct rte_fbarray memseg_arr;
+};
+
 /**
  * Lock page in physical memory and prevent from swapping.
  *
diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index f1d31de0d..634ca212f 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -20,11 +20,13 @@
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
 #include <rte_memcpy.h>
+#include <rte_memzone.h>
 #include <rte_atomic.h>
 #include <rte_fbarray.h>
 
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "malloc_elem.h"
 #include "malloc_heap.h"
 #include "malloc_mp.h"
diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c
index 7c6112c4e..1f212f834 100644
--- a/lib/librte_eal/common/malloc_mp.c
+++ b/lib/librte_eal/common/malloc_mp.c
@@ -10,6 +10,7 @@
 #include <rte_string_fns.h>
 
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 
 #include "malloc_elem.h"
 #include "malloc_mp.h"
diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index 2cad7beaa..fecd9a964 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -25,6 +25,7 @@
 #include "malloc_elem.h"
 #include "malloc_heap.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 
 
 /* Free the memory space back to heap */
diff --git a/lib/librte_eal/freebsd/eal/Makefile b/lib/librte_eal/freebsd/eal/Makefile
index eb921275e..89131ea89 100644
--- a/lib/librte_eal/freebsd/eal/Makefile
+++ b/lib/librte_eal/freebsd/eal/Makefile
@@ -22,7 +22,7 @@ LDLIBS += -lrte_kvargs
 
 EXPORT_MAP := ../../rte_eal_version.map
 
-LIBABIVER := 10
+LIBABIVER := 11
 
 # specific to freebsd exec-env
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) := eal.c
diff --git a/lib/librte_eal/freebsd/eal/eal_memory.c b/lib/librte_eal/freebsd/eal/eal_memory.c
index 4b092e1f2..9b9a0577a 100644
--- a/lib/librte_eal/freebsd/eal/eal_memory.c
+++ b/lib/librte_eal/freebsd/eal/eal_memory.c
@@ -18,6 +18,7 @@
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
+#include "eal_memcfg.h"
 
 #define EAL_PAGE_SIZE (sysconf(_SC_PAGESIZE))
 
diff --git a/lib/librte_eal/linux/eal/Makefile b/lib/librte_eal/linux/eal/Makefile
index dfe8e9a49..0f5725e64 100644
--- a/lib/librte_eal/linux/eal/Makefile
+++ b/lib/librte_eal/linux/eal/Makefile
@@ -10,7 +10,7 @@ ARCH_DIR ?= $(RTE_ARCH)
 EXPORT_MAP := ../../rte_eal_version.map
 VPATH += $(RTE_SDK)/lib/librte_eal/common/arch/$(ARCH_DIR)
 
-LIBABIVER := 10
+LIBABIVER := 11
 
 VPATH += $(RTE_SDK)/lib/librte_eal/common
 
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 8a0b387ce..f974cec1c 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -57,6 +57,7 @@
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
+#include "eal_memcfg.h"
 #include "eal_options.h"
 #include "eal_vfio.h"
 #include "hotplug_mp.h"
diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c
index 2019636fb..1f6a7c18f 100644
--- a/lib/librte_eal/linux/eal/eal_memalloc.c
+++ b/lib/librte_eal/linux/eal/eal_memalloc.c
@@ -44,6 +44,7 @@
 #include "eal_filesystem.h"
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_private.h"
 
 const int anonymous_hugepages_supported =
diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c
index 1853acea5..9c948a374 100644
--- a/lib/librte_eal/linux/eal/eal_memory.c
+++ b/lib/librte_eal/linux/eal/eal_memory.c
@@ -46,6 +46,7 @@
 
 #include "eal_private.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index 96a03a657..fdc884f70 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -15,6 +15,7 @@
 #include <rte_vfio.h>
 
 #include "eal_filesystem.h"
+#include "eal_memcfg.h"
 #include "eal_vfio.h"
 #include "eal_private.h"
 
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index ccd5b85b8..2751023a9 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -12,7 +12,7 @@ subdir('common') # defines common_sources, common_objs, etc.
 dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env + '/eal')
 
-version = 10  # the version of the EAL API
+version = 11  # the version of the EAL API
 allow_experimental_apis = true
 deps += 'kvargs'
 if dpdk_conf.has('RTE_USE_LIBBSD')
diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index b808ce99f..d3d019578 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -20,6 +20,7 @@
 #include <rte_ring.h>
 #include <rte_jhash.h>
 #include <rte_hash_crc.h>
+#include <rte_tailq.h>
 
 #include "rte_efd.h"
 #if defined(RTE_ARCH_X86)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 47cd0da5b..74d5bbd99 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -27,6 +27,7 @@
 #include <rte_ring.h>
 #include <rte_compat.h>
 #include <rte_vect.h>
+#include <rte_tailq.h>
 
 #include "rte_hash.h"
 #include "rte_cuckoo_hash.h"
diff --git a/lib/librte_hash/rte_fbk_hash.c b/lib/librte_hash/rte_fbk_hash.c
index db118c930..576e8e666 100644
--- a/lib/librte_hash/rte_fbk_hash.c
+++ b/lib/librte_hash/rte_fbk_hash.c
@@ -20,6 +20,7 @@
 #include <rte_cpuflags.h>
 #include <rte_log.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_fbk_hash.h"
 
diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index b91f74216..70c24ac1f 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -21,6 +21,7 @@
 #include <rte_errno.h>
 #include <rte_rwlock.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_lpm.h"
 
diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index 5af74a539..9b8aeb972 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -24,6 +24,7 @@
 #include <rte_hash.h>
 #include <assert.h>
 #include <rte_jhash.h>
+#include <rte_tailq.h>
 
 #include "rte_lpm6.h"
 
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index efed28dd9..e0e7f127e 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -10,6 +10,7 @@
 #include <rte_memory.h>
 #include <rte_malloc.h>
 #include <rte_errno.h>
+#include <rte_tailq.h>
 
 #include "rte_member.h"
 #include "rte_member_ht.h"
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 5c688d456..7260ce0be 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -30,6 +30,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_mempool.h"
 
diff --git a/lib/librte_rcu/rte_rcu_qsbr.h b/lib/librte_rcu/rte_rcu_qsbr.h
index 53a5a7165..c80f15c00 100644
--- a/lib/librte_rcu/rte_rcu_qsbr.h
+++ b/lib/librte_rcu/rte_rcu_qsbr.h
@@ -24,6 +24,7 @@
 extern "C" {
 #endif
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <inttypes.h>
diff --git a/lib/librte_reorder/rte_reorder.c b/lib/librte_reorder/rte_reorder.c
index ae6e3f578..3c9f0e2d0 100644
--- a/lib/librte_reorder/rte_reorder.c
+++ b/lib/librte_reorder/rte_reorder.c
@@ -11,6 +11,7 @@
 #include <rte_eal_memconfig.h>
 #include <rte_errno.h>
 #include <rte_malloc.h>
+#include <rte_tailq.h>
 
 #include "rte_reorder.h"
 
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index 9ea26a631..b30b2aa7b 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -30,6 +30,7 @@
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_spinlock.h>
+#include <rte_tailq.h>
 
 #include "rte_ring.h"
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v5 5/9] eal: remove packed attribute from mcfg structure
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
                         ` (4 preceding siblings ...)
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 4/9] eal: hide shared memory config Anatoly Burakov
@ 2019-07-05 17:26       ` Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 6/9] eal: uninline wait for mcfg complete function Anatoly Burakov
                         ` (3 subsequent siblings)
  9 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 17:26 UTC (permalink / raw)
  To: dev; +Cc: thomas, david.marchand, stephen

There is no reason to pack the memconfig structure, and doing so
gives out warnings in some static analyzers. Fix it by removing
the packed attributed.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eal/common/eal_memcfg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 74f6159c6..e5b90e31d 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -67,7 +67,7 @@ struct rte_mem_config {
 	/**< stored single file segments parameter. */
 
 	uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
-} __attribute__((packed));
+};
 
 static inline void
 rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v5 6/9] eal: uninline wait for mcfg complete function
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
                         ` (5 preceding siblings ...)
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 5/9] eal: remove packed attribute from mcfg structure Anatoly Burakov
@ 2019-07-05 17:26       ` Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 7/9] eal: unify and move " Anatoly Burakov
                         ` (2 subsequent siblings)
  9 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 17:26 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, thomas, david.marchand, stephen

Currently, the function to wait until config completion is
static inline for no reason. Move its implementation to
an EAL common file.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 10 ++++++++++
 lib/librte_eal/common/eal_memcfg.h      | 10 +++-------
 lib/librte_eal/freebsd/eal/eal.c        |  3 ++-
 lib/librte_eal/linux/eal/eal.c          |  2 +-
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 337890a61..30969c6bf 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -7,6 +7,16 @@
 
 #include "eal_memcfg.h"
 
+void
+eal_mcfg_wait_complete(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	/* wait until shared mem_config finish initialising */
+	while (mcfg->magic != RTE_MAGIC)
+		rte_pause();
+}
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index e5b90e31d..6c08652fe 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -69,12 +69,8 @@ struct rte_mem_config {
 	uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
 };
 
-static inline void
-rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg)
-{
-	/* wait until shared mem_config finish initialising */
-	while (mcfg->magic != RTE_MAGIC)
-		rte_pause();
-}
+/* wait until primary process initialization is complete */
+void
+eal_mcfg_wait_complete(void);
 
 #endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 71ba380e0..78022f68a 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -52,6 +52,7 @@
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
 #include "eal_options.h"
+#include "eal_memcfg.h"
 
 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
 
@@ -382,7 +383,7 @@ rte_config_init(void)
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
 			return -1;
-		rte_eal_mcfg_wait_complete(rte_config.mem_config);
+		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
 		break;
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index f974cec1c..561a4f3f3 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -506,7 +506,7 @@ rte_config_init(void)
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
 			return -1;
-		rte_eal_mcfg_wait_complete(rte_config.mem_config);
+		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
 		eal_update_internal_config();
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v5 7/9] eal: unify and move mcfg complete function
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
                         ` (6 preceding siblings ...)
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 6/9] eal: uninline wait for mcfg complete function Anatoly Burakov
@ 2019-07-05 17:26       ` Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 8/9] eal: unify internal config initialization Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 9/9] eal: prevent different primary/secondary process versions Anatoly Burakov
  9 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 17:26 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, thomas, david.marchand, stephen

Currently, mcfg completion function exists in two independent
implementations doing the same thing, which is bug prone.
Unify the two functions and move them into one place.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 14 ++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  4 ++++
 lib/librte_eal/freebsd/eal/eal.c        | 12 +-----------
 lib/librte_eal/linux/eal/eal.c          | 12 +-----------
 4 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 30969c6bf..dc6665d6a 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -5,8 +5,22 @@
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
 
+#include "eal_internal_cfg.h"
 #include "eal_memcfg.h"
 
+void
+eal_mcfg_complete(void)
+{
+	struct rte_config *cfg = rte_eal_get_configuration();
+	struct rte_mem_config *mcfg = cfg->mem_config;
+
+	/* ALL shared mem_config related INIT DONE */
+	if (cfg->process_type == RTE_PROC_PRIMARY)
+		mcfg->magic = RTE_MAGIC;
+
+	internal_config.init_complete = 1;
+}
+
 void
 eal_mcfg_wait_complete(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 6c08652fe..417324aab 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -73,4 +73,8 @@ struct rte_mem_config {
 void
 eal_mcfg_wait_complete(void);
 
+/* set mem config as complete */
+void
+eal_mcfg_complete(void);
+
 #endif /* EAL_MEMCFG_H */
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 78022f68a..340f7dd6c 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -632,16 +632,6 @@ sync_func(__attribute__((unused)) void *arg)
 	return 0;
 }
 
-inline static void
-rte_eal_mcfg_complete(void)
-{
-	/* ALL shared mem_config related INIT DONE */
-	if (rte_config.process_type == RTE_PROC_PRIMARY)
-		rte_config.mem_config->magic = RTE_MAGIC;
-
-	internal_config.init_complete = 1;
-}
-
 /* return non-zero if hugepages are enabled. */
 int rte_eal_has_hugepages(void)
 {
@@ -919,7 +909,7 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	rte_eal_mcfg_complete();
+	eal_mcfg_complete();
 
 	/* Call each registered callback, if enabled */
 	rte_option_init();
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 561a4f3f3..e15eacffc 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -934,16 +934,6 @@ sync_func(__attribute__((unused)) void *arg)
 	return 0;
 }
 
-inline static void
-rte_eal_mcfg_complete(void)
-{
-	/* ALL shared mem_config related INIT DONE */
-	if (rte_config.process_type == RTE_PROC_PRIMARY)
-		rte_config.mem_config->magic = RTE_MAGIC;
-
-	internal_config.init_complete = 1;
-}
-
 /*
  * Request iopl privilege for all RPL, returns 0 on success
  * iopl() call is mostly for the i386 architecture. For other architectures,
@@ -1267,7 +1257,7 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	rte_eal_mcfg_complete();
+	eal_mcfg_complete();
 
 	/* Call each registered callback, if enabled */
 	rte_option_init();
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v5 8/9] eal: unify internal config initialization
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
                         ` (7 preceding siblings ...)
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 7/9] eal: unify and move " Anatoly Burakov
@ 2019-07-05 17:26       ` Anatoly Burakov
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 9/9] eal: prevent different primary/secondary process versions Anatoly Burakov
  9 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 17:26 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, thomas, david.marchand, stephen

Currently, each EAL will update internal/shared config in their
own way at init, resulting in needless duplication of code and
OS-dependent behavior. Move the functions to a common file and
add missing FreeBSD steps.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 18 ++++++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  8 ++++++++
 lib/librte_eal/freebsd/eal/eal.c        |  2 ++
 lib/librte_eal/linux/eal/eal.c          | 22 ++--------------------
 4 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index dc6665d6a..fe8d2b726 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -31,6 +31,24 @@ eal_mcfg_wait_complete(void)
 		rte_pause();
 }
 
+void
+eal_mcfg_update_internal(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	internal_config.legacy_mem = mcfg->legacy_mem;
+	internal_config.single_file_segments = mcfg->single_file_segments;
+}
+
+void
+eal_mcfg_update_from_internal(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	mcfg->legacy_mem = internal_config.legacy_mem;
+	mcfg->single_file_segments = internal_config.single_file_segments;
+}
+
 void
 rte_mcfg_mem_read_lock(void)
 {
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 417324aab..573233896 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -69,6 +69,14 @@ struct rte_mem_config {
 	uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */
 };
 
+/* update internal config from shared mem config */
+void
+eal_mcfg_update_internal(void);
+
+/* update shared mem config from internal config */
+void
+eal_mcfg_update_from_internal(void);
+
 /* wait until primary process initialization is complete */
 void
 eal_mcfg_wait_complete(void);
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 340f7dd6c..ec1650c43 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -379,6 +379,7 @@ rte_config_init(void)
 	case RTE_PROC_PRIMARY:
 		if (rte_eal_config_create() < 0)
 			return -1;
+		eal_mcfg_update_from_internal();
 		break;
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
@@ -386,6 +387,7 @@ rte_config_init(void)
 		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
+		eal_mcfg_update_internal();
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index e15eacffc..445d72f0c 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -473,24 +473,6 @@ eal_proc_type_detect(void)
 	return ptype;
 }
 
-/* copies data from internal config to shared config */
-static void
-eal_update_mem_config(void)
-{
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	mcfg->legacy_mem = internal_config.legacy_mem;
-	mcfg->single_file_segments = internal_config.single_file_segments;
-}
-
-/* copies data from shared config to internal config */
-static void
-eal_update_internal_config(void)
-{
-	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
-	internal_config.legacy_mem = mcfg->legacy_mem;
-	internal_config.single_file_segments = mcfg->single_file_segments;
-}
-
 /* Sets up rte_config structure with the pointer to shared memory config.*/
 static int
 rte_config_init(void)
@@ -501,7 +483,7 @@ rte_config_init(void)
 	case RTE_PROC_PRIMARY:
 		if (rte_eal_config_create() < 0)
 			return -1;
-		eal_update_mem_config();
+		eal_mcfg_update_from_internal();
 		break;
 	case RTE_PROC_SECONDARY:
 		if (rte_eal_config_attach() < 0)
@@ -509,7 +491,7 @@ rte_config_init(void)
 		eal_mcfg_wait_complete();
 		if (rte_eal_config_reattach() < 0)
 			return -1;
-		eal_update_internal_config();
+		eal_mcfg_update_internal();
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* [dpdk-dev] [PATCH v5 9/9] eal: prevent different primary/secondary process versions
  2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
                         ` (8 preceding siblings ...)
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 8/9] eal: unify internal config initialization Anatoly Burakov
@ 2019-07-05 17:26       ` Anatoly Burakov
  9 siblings, 0 replies; 117+ messages in thread
From: Anatoly Burakov @ 2019-07-05 17:26 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, thomas, david.marchand, stephen

Currently, nothing stops DPDK to attempt to run primary and
secondary processes while having different versions. This
can lead to all sorts of weird behavior and makes it harder
to maintain compatibility without breaking ABI every once
in a while.

Fix it by explicitly disallowing running different DPDK
versions as primary and secondary processes.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_eal/common/eal_common_mcfg.c | 15 +++++++++++++++
 lib/librte_eal/common/eal_memcfg.h      |  6 ++++++
 lib/librte_eal/freebsd/eal/eal.c        |  4 ++++
 lib/librte_eal/linux/eal/eal.c          |  4 ++++
 4 files changed, 29 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index fe8d2b726..1825d9083 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -4,6 +4,7 @@
 
 #include <rte_config.h>
 #include <rte_eal_memconfig.h>
+#include <rte_version.h>
 
 #include "eal_internal_cfg.h"
 #include "eal_memcfg.h"
@@ -31,6 +32,18 @@ eal_mcfg_wait_complete(void)
 		rte_pause();
 }
 
+int
+eal_mcfg_check_version(void)
+{
+	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+	/* check if version from memconfig matches compiled in macro */
+	if (mcfg->version != RTE_VERSION)
+		return -1;
+
+	return 0;
+}
+
 void
 eal_mcfg_update_internal(void)
 {
@@ -47,6 +60,8 @@ eal_mcfg_update_from_internal(void)
 
 	mcfg->legacy_mem = internal_config.legacy_mem;
 	mcfg->single_file_segments = internal_config.single_file_segments;
+	/* record current DPDK version */
+	mcfg->version = RTE_VERSION;
 }
 
 void
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index 573233896..030f903ad 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -19,6 +19,8 @@
  */
 struct rte_mem_config {
 	volatile uint32_t magic;   /**< Magic number - sanity check. */
+	uint32_t version;
+	/**< Prevent secondary processes using different DPDK versions. */
 
 	/* memory topology */
 	uint32_t nchannel;    /**< Number of channels (0 if unknown). */
@@ -81,6 +83,10 @@ eal_mcfg_update_from_internal(void);
 void
 eal_mcfg_wait_complete(void);
 
+/* check if DPDK version of current process matches one stored in the config */
+int
+eal_mcfg_check_version(void);
+
 /* set mem config as complete */
 void
 eal_mcfg_complete(void);
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index ec1650c43..139d021d9 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -385,6 +385,10 @@ rte_config_init(void)
 		if (rte_eal_config_attach() < 0)
 			return -1;
 		eal_mcfg_wait_complete();
+		if (eal_mcfg_check_version() < 0) {
+			RTE_LOG(ERR, EAL, "Primary and secondary process DPDK version mismatch\n");
+			return -1;
+		}
 		if (rte_eal_config_reattach() < 0)
 			return -1;
 		eal_mcfg_update_internal();
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 445d72f0c..47ac3b025 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -489,6 +489,10 @@ rte_config_init(void)
 		if (rte_eal_config_attach() < 0)
 			return -1;
 		eal_mcfg_wait_complete();
+		if (eal_mcfg_check_version() < 0) {
+			RTE_LOG(ERR, EAL, "Primary and secondary process DPDK version mismatch\n");
+			return -1;
+		}
 		if (rte_eal_config_reattach() < 0)
 			return -1;
 		eal_mcfg_update_internal();
-- 
2.17.1

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v5 4/9] eal: hide shared memory config
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 4/9] eal: hide shared memory config Anatoly Burakov
@ 2019-07-05 19:08         ` Thomas Monjalon
  2019-07-08  9:22           ` Burakov, Anatoly
  0 siblings, 1 reply; 117+ messages in thread
From: Thomas Monjalon @ 2019-07-05 19:08 UTC (permalink / raw)
  To: Anatoly Burakov
  Cc: dev, Neil Horman, John McNamara, Marko Kovacevic,
	Konstantin Ananyev, David Hunt, Bruce Richardson, Byron Marohn,
	Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Honnappa Nagarahalli, Reshma Pattan, david.marchand, stephen

05/07/2019 19:26, Anatoly Burakov:
> --- a/lib/librte_eal/common/include/rte_fbarray.h
> +++ b/lib/librte_eal/common/include/rte_fbarray.h
> @@ -34,7 +34,6 @@
>  extern "C" {
>  #endif
>  
> -#include <stdbool.h>
>  #include <stdio.h>

It triggers some compilation errors in mlx4 and mlx5:
	fatal error: unknown type name 'bool'
I will try to fix them.



^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/9] Make shared memory config non-public
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 0/9] " Anatoly Burakov
@ 2019-07-05 19:30         ` David Marchand
  2019-07-05 21:09         ` Thomas Monjalon
  1 sibling, 0 replies; 117+ messages in thread
From: David Marchand @ 2019-07-05 19:30 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Thomas Monjalon, Stephen Hemminger

On Fri, Jul 5, 2019 at 7:26 PM Anatoly Burakov <anatoly.burakov@intel.com>
wrote:

> This patchset removes the shared memory config from public
> API, and replaces all usages of said config with new API
> calls.
>
> A lot of the patchset is a search-and-replace job and should
> be pretty easy to review. The rest are pretty trivial EAL
> changes.
>
> v5:
> - Accidentally squashed last patch into another patch
>

Better this way :-)

Thanks Anatoly!


-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/9] Make shared memory config non-public
  2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 0/9] " Anatoly Burakov
  2019-07-05 19:30         ` David Marchand
@ 2019-07-05 21:09         ` Thomas Monjalon
  2019-07-31 10:07           ` David Marchand
  1 sibling, 1 reply; 117+ messages in thread
From: Thomas Monjalon @ 2019-07-05 21:09 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, david.marchand, stephen

05/07/2019 19:26, Anatoly Burakov:
> This patchset removes the shared memory config from public
> API, and replaces all usages of said config with new API
> calls.
> 
> A lot of the patchset is a search-and-replace job and should
> be pretty easy to review. The rest are pretty trivial EAL
> changes.

Applied, thanks




^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v5 4/9] eal: hide shared memory config
  2019-07-05 19:08         ` Thomas Monjalon
@ 2019-07-08  9:22           ` Burakov, Anatoly
  2019-07-08  9:38             ` Thomas Monjalon
  0 siblings, 1 reply; 117+ messages in thread
From: Burakov, Anatoly @ 2019-07-08  9:22 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Neil Horman, John McNamara, Marko Kovacevic,
	Konstantin Ananyev, David Hunt, Bruce Richardson, Byron Marohn,
	Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Honnappa Nagarahalli, Reshma Pattan, david.marchand, stephen

On 05-Jul-19 8:08 PM, Thomas Monjalon wrote:
> 05/07/2019 19:26, Anatoly Burakov:
>> --- a/lib/librte_eal/common/include/rte_fbarray.h
>> +++ b/lib/librte_eal/common/include/rte_fbarray.h
>> @@ -34,7 +34,6 @@
>>   extern "C" {
>>   #endif
>>   
>> -#include <stdbool.h>
>>   #include <stdio.h>
> 
> It triggers some compilation errors in mlx4 and mlx5:
> 	fatal error: unknown type name 'bool'
> I will try to fix them.
> 

They probably need to include stdbool. Not removing these broke 
everything else... I should get a mlx compilation setup.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v5 4/9] eal: hide shared memory config
  2019-07-08  9:22           ` Burakov, Anatoly
@ 2019-07-08  9:38             ` Thomas Monjalon
  0 siblings, 0 replies; 117+ messages in thread
From: Thomas Monjalon @ 2019-07-08  9:38 UTC (permalink / raw)
  To: Burakov, Anatoly
  Cc: dev, Neil Horman, John McNamara, Marko Kovacevic,
	Konstantin Ananyev, David Hunt, Bruce Richardson, Byron Marohn,
	Pablo de Lara Guarch, Yipeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Olivier Matz, Andrew Rybchenko,
	Honnappa Nagarahalli, Reshma Pattan, david.marchand, stephen

08/07/2019 11:22, Burakov, Anatoly:
> On 05-Jul-19 8:08 PM, Thomas Monjalon wrote:
> > 05/07/2019 19:26, Anatoly Burakov:
> >> --- a/lib/librte_eal/common/include/rte_fbarray.h
> >> +++ b/lib/librte_eal/common/include/rte_fbarray.h
> >> @@ -34,7 +34,6 @@
> >>   extern "C" {
> >>   #endif
> >>   
> >> -#include <stdbool.h>
> >>   #include <stdio.h>
> > 
> > It triggers some compilation errors in mlx4 and mlx5:
> > 	fatal error: unknown type name 'bool'
> > I will try to fix them.
> 
> They probably need to include stdbool. Not removing these broke 
> everything else... I should get a mlx compilation setup.

You can check the changes I did in mlx4/mlx5 to fix compilation:
	http://git.dpdk.org/dpdk/commit/?id=028669bc9f0
bool type was over used in some places.

About checking mlx compilation, you just need to install rdma-core
which is packaged in all good distributions.



^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/9] Make shared memory config non-public
  2019-07-05 21:09         ` Thomas Monjalon
@ 2019-07-31 10:07           ` David Marchand
  2019-07-31 10:32             ` Burakov, Anatoly
  0 siblings, 1 reply; 117+ messages in thread
From: David Marchand @ 2019-07-31 10:07 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Stephen Hemminger, Thomas Monjalon

Hello Anatoly,

On Fri, Jul 5, 2019 at 11:09 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 05/07/2019 19:26, Anatoly Burakov:
> > This patchset removes the shared memory config from public
> > API, and replaces all usages of said config with new API
> > calls.
> >
> > A lot of the patchset is a search-and-replace job and should
> > be pretty easy to review. The rest are pretty trivial EAL
> > changes.
>
> Applied, thanks

As a followup, we can cleanup the unneeded rte_eal_memconfig.h include
that are all over the tree.


-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/9] Make shared memory config non-public
  2019-07-31 10:07           ` David Marchand
@ 2019-07-31 10:32             ` Burakov, Anatoly
  2019-07-31 10:48               ` David Marchand
  0 siblings, 1 reply; 117+ messages in thread
From: Burakov, Anatoly @ 2019-07-31 10:32 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Stephen Hemminger, Thomas Monjalon

On 31-Jul-19 11:07 AM, David Marchand wrote:
> Hello Anatoly,
> 
> On Fri, Jul 5, 2019 at 11:09 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>>
>> 05/07/2019 19:26, Anatoly Burakov:
>>> This patchset removes the shared memory config from public
>>> API, and replaces all usages of said config with new API
>>> calls.
>>>
>>> A lot of the patchset is a search-and-replace job and should
>>> be pretty easy to review. The rest are pretty trivial EAL
>>> changes.
>>
>> Applied, thanks
> 
> As a followup, we can cleanup the unneeded rte_eal_memconfig.h include
> that are all over the tree.
> 

Nice bit of sneaking in an AR with the "we" there :) sure, we can.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 117+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/9] Make shared memory config non-public
  2019-07-31 10:32             ` Burakov, Anatoly
@ 2019-07-31 10:48               ` David Marchand
  0 siblings, 0 replies; 117+ messages in thread
From: David Marchand @ 2019-07-31 10:48 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: dev, Stephen Hemminger, Thomas Monjalon

On Wed, Jul 31, 2019 at 12:32 PM Burakov, Anatoly
<anatoly.burakov@intel.com> wrote:
>
> On 31-Jul-19 11:07 AM, David Marchand wrote:
> > Hello Anatoly,
> >
> > On Fri, Jul 5, 2019 at 11:09 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> >>
> >> 05/07/2019 19:26, Anatoly Burakov:
> >>> This patchset removes the shared memory config from public
> >>> API, and replaces all usages of said config with new API
> >>> calls.
> >>>
> >>> A lot of the patchset is a search-and-replace job and should
> >>> be pretty easy to review. The rest are pretty trivial EAL
> >>> changes.
> >>
> >> Applied, thanks
> >
> > As a followup, we can cleanup the unneeded rte_eal_memconfig.h include
> > that are all over the tree.
> >
>
> Nice bit of sneaking in an AR with the "we" there :) sure, we can.

Eheh, I will put it in my todolist for 19.11.


-- 
David Marchand

^ permalink raw reply	[flat|nested] 117+ messages in thread

end of thread, other threads:[~2019-07-31 10:48 UTC | newest]

Thread overview: 117+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-29 16:30 [dpdk-dev] [PATCH 00/25] Make shared memory config non-public Anatoly Burakov
2019-05-29 16:30 ` [dpdk-dev] [PATCH 01/25] eal: add API to lock/unlock memory hotplug Anatoly Burakov
2019-05-29 16:41   ` Stephen Hemminger
2019-05-29 16:30 ` [dpdk-dev] [PATCH 02/25] bus/fslmc: use new memory locking API Anatoly Burakov
2019-06-03  6:41   ` Shreyansh Jain
2019-05-29 16:30 ` [dpdk-dev] [PATCH 03/25] net/mlx4: " Anatoly Burakov
2019-05-29 16:30 ` [dpdk-dev] [PATCH 04/25] net/mlx5: " Anatoly Burakov
2019-05-29 16:30 ` [dpdk-dev] [PATCH 05/25] net/virtio: " Anatoly Burakov
2019-05-30  6:39   ` Tiwei Bie
2019-05-29 16:30 ` [dpdk-dev] [PATCH 06/25] mem: " Anatoly Burakov
2019-05-29 16:30 ` [dpdk-dev] [PATCH 07/25] malloc: " Anatoly Burakov
2019-05-29 16:30 ` [dpdk-dev] [PATCH 08/25] vfio: " Anatoly Burakov
2019-05-29 16:30 ` [dpdk-dev] [PATCH 09/25] eal: add EAL tailq list lock/unlock API Anatoly Burakov
2019-05-29 16:30 ` [dpdk-dev] [PATCH 10/25] acl: use new tailq locking API Anatoly Burakov
2019-05-29 16:30 ` [dpdk-dev] [PATCH 11/25] distributor: " Anatoly Burakov
2019-05-29 16:30 ` [dpdk-dev] [PATCH 12/25] efd: " Anatoly Burakov
2019-05-29 16:30 ` [dpdk-dev] [PATCH 13/25] eventdev: " Anatoly Burakov
2019-05-29 16:31 ` [dpdk-dev] [PATCH 14/25] hash: " Anatoly Burakov
2019-05-29 16:31 ` [dpdk-dev] [PATCH 15/25] lpm: " Anatoly Burakov
2019-05-29 16:31 ` [dpdk-dev] [PATCH 16/25] member: " Anatoly Burakov
2019-05-29 16:31 ` [dpdk-dev] [PATCH 17/25] mempool: " Anatoly Burakov
2019-05-29 16:47   ` Andrew Rybchenko
2019-05-29 16:31 ` [dpdk-dev] [PATCH 18/25] reorder: " Anatoly Burakov
2019-05-29 16:31 ` [dpdk-dev] [PATCH 19/25] ring: " Anatoly Burakov
2019-05-29 16:31 ` [dpdk-dev] [PATCH 20/25] stack: " Anatoly Burakov
2019-05-29 18:20   ` Eads, Gage
2019-05-29 16:31 ` [dpdk-dev] [PATCH 21/25] eal: add new API to lock/unlock mempool list Anatoly Burakov
2019-05-29 16:31 ` [dpdk-dev] [PATCH 22/25] mempool: use new mempool list locking API Anatoly Burakov
2019-05-29 16:50   ` Andrew Rybchenko
2019-05-29 16:31 ` [dpdk-dev] [PATCH 23/25] eal: remove unused macros Anatoly Burakov
2019-05-29 16:31 ` [dpdk-dev] [PATCH 24/25] net/ena: fix direct access to shared memory config Anatoly Burakov
2019-06-03  7:33   ` Michał Krawczyk
2019-06-03 13:36     ` Michał Krawczyk
2019-06-04 10:28       ` Burakov, Anatoly
2019-06-04 10:45         ` Michał Krawczyk
2019-06-04 12:38           ` Burakov, Anatoly
2019-05-29 16:31 ` [dpdk-dev] [PATCH 25/25] eal: hide " Anatoly Burakov
2019-05-29 16:40   ` Stephen Hemminger
2019-05-30  8:02     ` Burakov, Anatoly
2019-05-29 20:14   ` David Marchand
2019-05-29 20:11 ` [dpdk-dev] [PATCH 00/25] Make shared memory config non-public David Marchand
2019-05-30  8:07   ` Burakov, Anatoly
2019-05-30 10:15     ` Bruce Richardson
2019-06-03  9:42       ` Thomas Monjalon
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 00/14] " Anatoly Burakov
2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2019-06-27 15:36     ` Stephen Hemminger
2019-07-03  9:38     ` David Marchand
2019-07-03 10:47       ` Burakov, Anatoly
2019-07-04  8:09       ` David Marchand
2019-07-04 19:52         ` Thomas Monjalon
2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 0/8] " Anatoly Burakov
2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 0/9] " Anatoly Burakov
2019-07-05 19:30         ` David Marchand
2019-07-05 21:09         ` Thomas Monjalon
2019-07-31 10:07           ` David Marchand
2019-07-31 10:32             ` Burakov, Anatoly
2019-07-31 10:48               ` David Marchand
2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 1/9] eal: add API to lock/unlock memory hotplug Anatoly Burakov
2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 2/9] eal: add EAL tailq list lock/unlock API Anatoly Burakov
2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 3/9] eal: add new API to lock/unlock mempool list Anatoly Burakov
2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 4/9] eal: hide shared memory config Anatoly Burakov
2019-07-05 19:08         ` Thomas Monjalon
2019-07-08  9:22           ` Burakov, Anatoly
2019-07-08  9:38             ` Thomas Monjalon
2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 5/9] eal: remove packed attribute from mcfg structure Anatoly Burakov
2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 6/9] eal: uninline wait for mcfg complete function Anatoly Burakov
2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 7/9] eal: unify and move " Anatoly Burakov
2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 8/9] eal: unify internal config initialization Anatoly Burakov
2019-07-05 17:26       ` [dpdk-dev] [PATCH v5 9/9] eal: prevent different primary/secondary process versions Anatoly Burakov
2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 1/8] eal: add API to lock/unlock memory hotplug Anatoly Burakov
2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 2/8] eal: add EAL tailq list lock/unlock API Anatoly Burakov
2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 3/8] eal: add new API to lock/unlock mempool list Anatoly Burakov
2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 4/8] eal: hide shared memory config Anatoly Burakov
2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 5/8] eal: remove packed attribute from mcfg structure Anatoly Burakov
2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 6/8] eal: uninline wait for mcfg complete function Anatoly Burakov
2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 7/8] eal: unify and move " Anatoly Burakov
2019-07-05 13:10     ` [dpdk-dev] [PATCH v4 8/8] eal: unify internal config initialization Anatoly Burakov
2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 01/14] eal: add API to lock/unlock memory hotplug Anatoly Burakov
2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 02/14] drivers: use new memory locking API Anatoly Burakov
2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 03/14] lib: " Anatoly Burakov
2019-06-27 11:38   ` [dpdk-dev] [PATCH v3 04/14] eal: add EAL tailq list lock/unlock API Anatoly Burakov
2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 05/14] lib: use new tailq locking API Anatoly Burakov
2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 06/14] eal: add new API to lock/unlock mempool list Anatoly Burakov
2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 07/14] mempool: use new mempool list locking API Anatoly Burakov
2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 08/14] eal: remove unused macros Anatoly Burakov
2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 09/14] eal: hide shared memory config Anatoly Burakov
2019-07-04  7:43     ` David Marchand
2019-07-04 10:47       ` Burakov, Anatoly
2019-07-04 10:52         ` David Marchand
2019-07-04 19:51     ` Thomas Monjalon
2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 10/14] eal: remove packed attribute from mcfg structure Anatoly Burakov
2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 11/14] eal: uninline wait for mcfg complete function Anatoly Burakov
2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 12/14] eal: unify and move " Anatoly Burakov
2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 13/14] eal: unify internal config initialization Anatoly Burakov
2019-07-04  7:50     ` David Marchand
2019-07-04  7:56       ` David Marchand
2019-07-04 10:50         ` Burakov, Anatoly
2019-07-04 10:54           ` David Marchand
2019-07-04 11:26             ` Burakov, Anatoly
2019-06-27 11:39   ` [dpdk-dev] [PATCH v3 14/14] eal: prevent different primary/secondary process versions Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 01/14] eal: add API to lock/unlock memory hotplug Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 02/14] drivers: use new memory locking API Anatoly Burakov
2019-06-27  9:24   ` Hemant Agrawal
2019-06-28 15:21   ` Yongseok Koh
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 03/14] lib: " Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 04/14] eal: add EAL tailq list lock/unlock API Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 05/14] lib: use new tailq locking API Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 06/14] eal: add new API to lock/unlock mempool list Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 07/14] mempool: use new mempool list locking API Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 08/14] eal: remove unused macros Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 09/14] eal: hide shared memory config Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 10/14] eal: remove packed attribute from mcfg structure Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 11/14] eal: uninline wait for mcfg complete function Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 12/14] eal: unify and move " Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 13/14] eal: unify internal config initialization Anatoly Burakov
2019-06-25 16:05 ` [dpdk-dev] [PATCH v2 14/14] eal: prevent different primary/secondary process versions Anatoly Burakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).