From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8B2CA054B; Thu, 16 Jul 2020 15:38:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 374301D557; Thu, 16 Jul 2020 15:38:44 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id E40231D526; Thu, 16 Jul 2020 15:38:39 +0200 (CEST) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 915F35F092CE6B63138D; Thu, 16 Jul 2020 21:38:33 +0800 (CST) Received: from localhost (10.174.185.168) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Thu, 16 Jul 2020 21:38:27 +0800 From: wangyunjian To: , CC: , , Yunjian Wang , Date: Thu, 16 Jul 2020 21:38:09 +0800 Message-ID: X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.185.168] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 1/1] eal/linux: do not create user mem map repeatedly when it exists X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yunjian Wang 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@dpdk.org Signed-off-by: Yunjian Wang --- 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