DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal/linux: add operation LOCK_NB to flock()
@ 2021-03-25  8:21 xiangxia.m.yue
  2021-04-13  8:32 ` Tonghao Zhang
  2021-04-15 14:24 ` Burakov, Anatoly
  0 siblings, 2 replies; 4+ messages in thread
From: xiangxia.m.yue @ 2021-03-25  8:21 UTC (permalink / raw)
  To: anatoly.burakov; +Cc: dev, Tonghao Zhang

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

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 <xiangxia.m.yue@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-30  3:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-25  8:21 [dpdk-dev] [PATCH] eal/linux: add operation LOCK_NB to flock() xiangxia.m.yue
2021-04-13  8:32 ` Tonghao Zhang
2021-04-15 14:24 ` Burakov, Anatoly
2023-06-30  3:47   ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).