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 6CE02A0A02; Thu, 25 Mar 2021 09:25:45 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB0A44067B; Thu, 25 Mar 2021 09:25:44 +0100 (CET) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id 3143640147 for ; Thu, 25 Mar 2021 09:25:44 +0100 (CET) Received: by mail-pj1-f44.google.com with SMTP id kr3-20020a17090b4903b02900c096fc01deso602565pjb.4 for ; Thu, 25 Mar 2021 01:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=75SlC4+CLdq/Zzd0TDDT1gtD5LAJ7F4NGmVC3Ho7h14=; b=N6yjn79IvVyd+caj+/lEhvGOdlVjewhVDVSmwbl2a6V8xUs9omJExQYtczajs1QlUI WQHJHPRulfydeC4GBFFeuOFJhvHse3/mOHb2Oq1/z8TRKDNpyq5UlSx8bQUQ90jjzGv1 2TgQQq3BX1ZDS0WwCGU2jPDQMAHKWf2gTqp1hh2S8uThRRQ3fEWr8Ywjsh4+8LHkJBva 4yZulRM4JZaDLZoEQ0qXsZhCLBVoDWoGSTJOq3aRjqViwDDUgSCCKjjDHqJ2FN3eezQH fRLlnsbxyGY1sl3m4rPDF8Pz7y1s2YZBWk774p64NjUabC/az2v+VmJIWumk4KHHWAmz nDrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=75SlC4+CLdq/Zzd0TDDT1gtD5LAJ7F4NGmVC3Ho7h14=; b=JUKOpBZ+1Dv3j4iBvXwHS2NocB2mk9soH1zb8uT2pMVxjEXGPQomQqxlCeF4jHpmwG 6k4dCSioRuxs18M/dZNnGNootBcXw6/y6xfTo7kG2CTEgNTDZ9/be7JjbchaJMWH12QL TmF2Sl2QfC17m3ifre/k7HoK4vBc5tUS8Csj/6dVOmhLG+wXoyUSsaWnuB7Q9QRkCuAM 9nL19VbK1pAobxUVKeDxRp9znZtrgLttYx88zfcmEQSSUmbxMrWXHHyxOGqN7O3QD1bn x5VEBcjvAvtPFsP1VSc0NhgZmUA7YgjVhVmkWlf7UdCNhE7YJhwY8D3hzHrqChwM6upX er5Q== X-Gm-Message-State: AOAM532rClkSxgnLq8lRw0pbhLUr5brPedNx2VdYt9rcoAHBo7v7V+ka D3Nik5uNd9bhUm9ryOuuWms= X-Google-Smtp-Source: ABdhPJxsI0s8BQiv5/R6i22q3zJ7ynLsT24/ae1IBE2vq/p8QoaD+1LvUoIvtxhguRXsmMXTql5uHw== X-Received: by 2002:a17:90b:284:: with SMTP id az4mr7815463pjb.12.1616660743289; Thu, 25 Mar 2021 01:25:43 -0700 (PDT) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id q95sm4924991pjq.20.2021.03.25.01.25.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Mar 2021 01:25:42 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: anatoly.burakov@intel.com Cc: dev@dpdk.org, Tonghao Zhang Date: Thu, 25 Mar 2021 16:21:25 +0800 Message-Id: <20210325082125.37488-1-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 Subject: [dpdk-dev] [PATCH] eal/linux: add operation LOCK_NB to flock() 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" From: Tonghao Zhang The hugepage of different size, 2MB, 1GB may be mounted on the same directory (e.g /dev/hugepages). Then dpdk primary process will be blocked. To address this issue, add the LOCK_NB flags to flock(). $ cat /proc/mounts ... none /dev/hugepages hugetlbfs rw,seclabel,relatime,pagesize=1024M 0 0 none /dev/hugepages hugetlbfs rw,seclabel,relatime,pagesize=2M 0 0 Add more details for err logs. Signed-off-by: Tonghao Zhang --- lib/librte_eal/linux/eal_hugepage_info.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/linux/eal_hugepage_info.c b/lib/librte_eal/linux/eal_hugepage_info.c index d97792cadeb6..1ff76e539053 100644 --- a/lib/librte_eal/linux/eal_hugepage_info.c +++ b/lib/librte_eal/linux/eal_hugepage_info.c @@ -451,9 +451,12 @@ hugepage_info_init(void) hpi->lock_descriptor = open(hpi->hugedir, O_RDONLY); /* if blocking lock failed */ - if (flock(hpi->lock_descriptor, LOCK_EX) == -1) { + if (flock(hpi->lock_descriptor, LOCK_EX | LOCK_NB) == -1) { RTE_LOG(CRIT, EAL, - "Failed to lock hugepage directory!\n"); + "Failed to lock hugepage directory! " + "The hugepage dir (%s) was locked by " + "other processes or self twice.\n", + hpi->hugedir); break; } /* clear out the hugepages dir from unused pages */ -- 2.27.0