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 C08F1A0C47 for ; Mon, 13 Sep 2021 13:06:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B64C0410E5; Mon, 13 Sep 2021 13:06:46 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 9DA374014F; Mon, 13 Sep 2021 13:06:43 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10105"; a="243959190" X-IronPort-AV: E=Sophos;i="5.85,288,1624345200"; d="scan'208";a="243959190" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2021 04:06:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,288,1624345200"; d="scan'208";a="551567670" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by fmsmga002.fm.intel.com with ESMTP; 13 Sep 2021 04:06:40 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: anatoly.burakov@intel.com, david.marchand@redhat.com, Bruce Richardson , stable@dpdk.org Date: Mon, 13 Sep 2021 12:06:35 +0100 Message-Id: <20210913110635.130387-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH] eal/freebsd: lock memory device to prevent conflicts X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 --- 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", -- 2.30.2