[dpdk-stable] [PATCH] eal/freebsd: lock memory device to prevent conflicts

Burakov, Anatoly anatoly.burakov at intel.com
Mon Sep 13 15:14:55 CEST 2021


On 13-Sep-21 12:06 PM, Bruce Richardson wrote:
> Only a single DPDK process on the system can be using the /dev/contigmem
> mappings at a time, but this was never explicitly enforced, e.g. when
> using --in-memory flag on two processes. To prevent possible conflict
> issues, we lock the dev node when it's in use, preventing other DPDK
> processes from starting up and causing problems for us.
> 
> Fixes: 764bf26873b9 ("add FreeBSD support")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
> ---
>   lib/eal/freebsd/eal_hugepage_info.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/lib/eal/freebsd/eal_hugepage_info.c b/lib/eal/freebsd/eal_hugepage_info.c
> index 408f054f7a..4a8d87c23e 100644
> --- a/lib/eal/freebsd/eal_hugepage_info.c
> +++ b/lib/eal/freebsd/eal_hugepage_info.c
> @@ -90,6 +90,10 @@ eal_hugepage_info_init(void)
>   		RTE_LOG(ERR, EAL, "could not open "CONTIGMEM_DEV"\n");
>   		return -1;
>   	}
> +	if (flock(fd, LOCK_EX) < 0) {
> +		RTE_LOG(ERR, EAL, "could not lock memory. Is another DPDK process running?\n");
> +		return -1;
> +	}
>   
>   	if (buffer_size >= 1<<30)
>   		RTE_LOG(INFO, EAL, "Contigmem driver has %d buffers, each of size %dGB\n",
> 

This only gets triggered when regular init path is chosen, i.e. 
--no-huge still works. I'm a bit uneasy with --in-memory mode pretending 
to work on FreeBSD and Windows, but that's a separate problem :) As far 
as the patch goes, the problem it addresses does get fixed.

Reviewed-by: Anatoly Burakov <anatoly.burakov at intel.com>

-- 
Thanks,
Anatoly


More information about the stable mailing list