From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id B9CABA0A0A
	for <public@inbox.dpdk.org>; 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 A9C1B140D22;
	Thu, 25 Mar 2021 14:38:20 +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 <wangyunjian@huawei.com>
To: "dev@dpdk.org" <dev@dpdk.org>
CC: "david.marchand@redhat.com" <david.marchand@redhat.com>,
 "thomas@monjalon.net" <thomas@monjalon.net>, "anatoly.burakov@intel.com"
 <anatoly.burakov@intel.com>, "Lilijun (Jerry)" <jerry.lilijun@huawei.com>,
 xudingke <xudingke@huawei.com>, "stable@dpdk.org" <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: <ef5e51f4298743949c6ad7793c300fdf@huawei.com>
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-stable] [dpdk-dev] [PATCH v4] eal: fix create user mem
 map repeatedly when it exists
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org
Sender: "stable" <stable-bounces@dpdk.org>

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) <jerry.lilijun@huawei.com>; xu=
dingke
> <xudingke@huawei.com>; wangyunjian <wangyunjian@huawei.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v4] eal: fix create user mem map repeatedly wh=
en it
> exists
>=20
> From: Yunjian Wang <wangyunjian@huawei.com>
>=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 <wangyunjian@huawei.com>
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
> 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