From: Bruce Richardson Date: Mon, 13 Sep 2021 14:08:48 +0000 (+0100) Subject: eal/freebsd: lock memory device to prevent conflicts X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=47a4f2650c71d9197231a95c5df8f89d0f65e882;p=dpdk.git eal/freebsd: lock memory device to prevent conflicts 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@dpdk.org Signed-off-by: Bruce Richardson Reviewed-by: Anatoly Burakov --- diff --git a/lib/eal/freebsd/eal_hugepage_info.c b/lib/eal/freebsd/eal_hugepage_info.c index 408f054f7a..9dbe375bd3 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 | LOCK_NB) < 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",