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

wangyunjian wangyunjian at huawei.com
Thu Mar 25 14:38:13 CET 2021


Friendly ping.

> -----Original Message-----
> From: wangyunjian
> Sent: Monday, December 7, 2020 7:09 PM
> To: dev at dpdk.org
> Cc: david.marchand at redhat.com; thomas at monjalon.net;
> anatoly.burakov at intel.com; Lilijun (Jerry) <jerry.lilijun at huawei.com>; xudingke
> <xudingke at huawei.com>; wangyunjian <wangyunjian at huawei.com>;
> stable at dpdk.org
> Subject: [dpdk-dev] [PATCH v4] eal: fix create user mem map repeatedly when it
> exists
> 
> From: Yunjian Wang <wangyunjian at huawei.com>
> 
> 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 because it
> assumes that the API will never get called with the same mapping twice. This
> will result in duplicate entries in the user mem maps list.
> 
> Fix it by also checking for duplicate mappings, and skipping them if they are
> found.
> 
> 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>
> ---
> v4:
>   Update commit log suggested by Anatoly Burakov
> ---
>  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
> 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)) == 0)
> +		goto out;
> +
>  	if (left->addr + left->len != right->addr)
>  		return 0;
>  	if (left->iova + left->len != right->iova) @@ -175,6 +179,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