[dpdk-dev] [PATCH v3] eal: fix create user mem map repeatedly when it exists

wangyunjian wangyunjian at huawei.com
Fri Oct 16 11:28:45 CEST 2020


From: Yunjian Wang <wangyunjian at huawei.com>

Currently, a issue that a container has many devices and the
application will map the same memory many times. The kernel
driver returns EEXIST as long as there are overlapping memory
areas. As a result, we repeatedly create new user mem map entry
for the same memory segment and this will lead to no more space
for other user mem maps.

To resolve the issue, add support to remove the same entry in
the function compact_user_maps().

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

Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
Acked-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
v3:
   Only update commit log and title
---
 lib/librte_eal/linux/eal_vfio.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/librte_eal/linux/eal_vfio.c b/lib/librte_eal/linux/eal_vfio.c
index 380f2f44a..7cff51e16 100644
--- a/lib/librte_eal/linux/eal_vfio.c
+++ b/lib/librte_eal/linux/eal_vfio.c
@@ -167,6 +167,10 @@ adjust_map(struct user_mem_map *src, struct user_mem_map *end,
 static int
 merge_map(struct user_mem_map *left, struct user_mem_map *right)
 {
+	/* merge the same maps into one */
+	if (memcmp(left, right, sizeof(struct user_mem_map)) == 0)
+		goto out;
+
 	if (left->addr + left->len != right->addr)
 		return 0;
 	if (left->iova + left->len != right->iova)
@@ -174,6 +178,7 @@ merge_map(struct user_mem_map *left, struct user_mem_map *right)
 
 	left->len += right->len;
 
+out:
 	memset(right, 0, sizeof(*right));
 
 	return 1;
-- 
2.23.0



More information about the dev mailing list