From 11d7c0dcb34c302e38bb7e6ffc927826354c0431 Mon Sep 17 00:00:00 2001 From: Yifan Liu Date: Tue, 24 Sep 2024 11:47:52 +0800 Subject: [PATCH] dm: Fix concurrent acrn-dm hugetlb init race During init of hugetlb we check and create /run/hugepage/acrn folder. Concurrent acrn-dm instances might race between the time of check and create. This commit ignore EEXIST error when creating directory. Tracked-On: #8764 Signed-off-by: Yifan Liu --- devicemodel/core/hugetlb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/devicemodel/core/hugetlb.c b/devicemodel/core/hugetlb.c index 1978ba97e..2a0962ffc 100644 --- a/devicemodel/core/hugetlb.c +++ b/devicemodel/core/hugetlb.c @@ -555,8 +555,13 @@ bool init_hugetlb(void) path[i] = 0; if (access(path, F_OK) != 0) { if (mkdir(path, 0755) < 0) { - pr_err("mkdir %s failed.\n", path); - return -1; + /* We might have multiple acrn-dm instances booting VMs at + * the same time + */ + if (errno != EEXIST) { + pr_err("mkdir %s failed: %s\n", path, errormsg(errno)); + return false; + } } } path[i] = '/';