[dpdk-stable] [PATCH 1/1] eal/linux: do not create user mem map repeatedly when it exists

wangyunjian wangyunjian at huawei.com
Thu Jul 16 15:38:09 CEST 2020


From: Yunjian Wang <wangyunjian at huawei.com>

Currently, we will create new user mem map entry for the same memory
segment, but in fact it has already been added to the user mem maps.
It's not necessary to create it twice.

Fixes: 0cbce3a167f1 ("vfio: skip DMA map failure if already mapped")
Cc: stable at dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
---
 lib/librte_eal/linux/eal_vfio.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/librte_eal/linux/eal_vfio.c b/lib/librte_eal/linux/eal_vfio.c
index abb12a354..d8a8c39ab 100644
--- a/lib/librte_eal/linux/eal_vfio.c
+++ b/lib/librte_eal/linux/eal_vfio.c
@@ -1828,6 +1828,13 @@ container_dma_map(struct vfio_config *vfio_cfg, uint64_t vaddr, uint64_t iova,
 		ret = -1;
 		goto out;
 	}
+
+	/* we don't need create new user mem map entry
+	 * for the same memory segment.
+	 */
+	if (errno == EBUSY || errno == EEXIST)
+		goto out;
+
 	/* create new user mem map entry */
 	new_map = &user_mem_maps->maps[user_mem_maps->n_maps++];
 	new_map->addr = vaddr;
-- 
2.23.0




More information about the stable mailing list