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 B2047A0C45; Mon, 13 Sep 2021 16:09:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3CFBA410DC; Mon, 13 Sep 2021 16:09:09 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 50B8B40E28; Mon, 13 Sep 2021 16:09:07 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10105"; a="244008344" X-IronPort-AV: E=Sophos;i="5.85,290,1624345200"; d="scan'208";a="244008344" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2021 07:08:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,290,1624345200"; d="scan'208";a="528062209" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by fmsmga004.fm.intel.com with ESMTP; 13 Sep 2021 07:08:53 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , stable@dpdk.org, Anatoly Burakov Date: Mon, 13 Sep 2021 15:08:48 +0100 Message-Id: <20210913140848.184928-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210913110635.130387-1-bruce.richardson@intel.com> References: <20210913110635.130387-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] eal/freebsd: lock memory device to prevent conflicts X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- V2: Adding missing LOCK_NB flag to make sure the process doesn't sit waiting for the lock to be released 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..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", -- 2.30.2