From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 403DEA0A02; Thu, 25 Mar 2021 14:38:20 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3D834067B; Thu, 25 Mar 2021 14:38:19 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 7284640147; Thu, 25 Mar 2021 14:38:17 +0100 (CET) Received: from DGGEML402-HUB.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4F5mN74dw4zYNrq; Thu, 25 Mar 2021 21:36:23 +0800 (CST) Received: from dggpemm100008.china.huawei.com (7.185.36.125) by DGGEML402-HUB.china.huawei.com (10.3.17.38) with Microsoft SMTP Server (TLS) id 14.3.498.0; Thu, 25 Mar 2021 21:38:13 +0800 Received: from dggpemm500008.china.huawei.com (7.185.36.136) by dggpemm100008.china.huawei.com (7.185.36.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 25 Mar 2021 21:38:14 +0800 Received: from dggpemm500008.china.huawei.com ([7.185.36.136]) by dggpemm500008.china.huawei.com ([7.185.36.136]) with mapi id 15.01.2106.013; Thu, 25 Mar 2021 21:38:14 +0800 From: wangyunjian To: "dev@dpdk.org" CC: "david.marchand@redhat.com" , "thomas@monjalon.net" , "anatoly.burakov@intel.com" , "Lilijun (Jerry)" , xudingke , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4] eal: fix create user mem map repeatedly when it exists Thread-Index: AQHWzIlj/dLV1J85FUqTra5e7D4DDaqVXbZw Date: Thu, 25 Mar 2021 13:38:13 +0000 Message-ID: References: <1602840525-8848-1-git-send-email-wangyunjian@huawei.com> <1607339329-624-1-git-send-email-wangyunjian@huawei.com> In-Reply-To: <1607339329-624-1-git-send-email-wangyunjian@huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.242.151] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH v4] eal: fix create user mem map repeatedly when it exists X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Friendly ping. > -----Original Message----- > From: wangyunjian > Sent: Monday, December 7, 2020 7:09 PM > To: dev@dpdk.org > Cc: david.marchand@redhat.com; thomas@monjalon.net; > anatoly.burakov@intel.com; Lilijun (Jerry) ; xu= dingke > ; wangyunjian ; > stable@dpdk.org > Subject: [dpdk-dev] [PATCH v4] eal: fix create user mem map repeatedly wh= en it > exists >=20 > From: Yunjian Wang >=20 > Currently, user mem maps will check if the newly mapped area is adjacent = to > any existing mapping, but will not check if the mapping is identical beca= use it > assumes that the API will never get called with the same mapping twice. T= his > will result in duplicate entries in the user mem maps list. >=20 > Fix it by also checking for duplicate mappings, and skipping them if they= are > found. >=20 > Fixes: 0cbce3a167f1 ("vfio: skip DMA map failure if already mapped") > Cc: stable@dpdk.org >=20 > Signed-off-by: Yunjian Wang > Acked-by: Anatoly Burakov > --- > v4: > Update commit log suggested by Anatoly Burakov > --- > lib/librte_eal/linux/eal_vfio.c | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > diff --git a/lib/librte_eal/linux/eal_vfio.c b/lib/librte_eal/linux/eal_v= fio.c index > 050082444e..0967215783 100644 > --- a/lib/librte_eal/linux/eal_vfio.c > +++ b/lib/librte_eal/linux/eal_vfio.c > @@ -168,6 +168,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)) =3D=3D 0) > + goto out; > + > if (left->addr + left->len !=3D right->addr) > return 0; > if (left->iova + left->len !=3D right->iova) @@ -175,6 +179,7 @@ > merge_map(struct user_mem_map *left, struct user_mem_map *right) >=20 > left->len +=3D right->len; >=20 > +out: > memset(right, 0, sizeof(*right)); >=20 > return 1; > -- > 2.23.0