From: Philip Pronin Date: Mon, 5 May 2014 17:10:41 +0000 (-0700) Subject: ignore non-existent mount points in readHugePageSizes X-Git-Tag: v0.22.0~565 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=99b82090d699367c74ecc9d4c6e6acb9d0b276da;p=folly.git ignore non-existent mount points in readHugePageSizes Summary: Some of mount points may not exist (for example, if application is running from chroot and unshare hasn't been used). @override-unit-failures Test Plan: unicorn canary Reviewed By: tudorb@fb.com FB internal diff: D1311374 --- diff --git a/folly/experimental/io/HugePages.cpp b/folly/experimental/io/HugePages.cpp index d18167fd..5b4a0706 100644 --- a/folly/experimental/io/HugePages.cpp +++ b/folly/experimental/io/HugePages.cpp @@ -170,16 +170,21 @@ HugePageSizeVec readHugePageSizes() { if (pos == sizeVec.end() || pos->size != pageSize) { throw std::runtime_error("Mount page size not found"); } - if (pos->mountPoint.empty()) { - // Store mount point - pos->mountPoint = fs::canonical(fs::path(parts[1].begin(), - parts[1].end())); - - struct stat st; - checkUnixError(stat(pos->mountPoint.c_str(), &st), - "stat hugepage mountpoint failed"); - pos->device = st.st_dev; + if (!pos->mountPoint.empty()) { + // Only one mount point per page size is allowed + return; } + + // Store mount point + fs::path path(parts[1].begin(), parts[1].end()); + struct stat st; + const int ret = stat(path.c_str(), &st); + if (ret == -1 && errno == ENOENT) { + return; + } + checkUnixError(ret, "stat hugepage mountpoint failed"); + pos->mountPoint = fs::canonical(path); + pos->device = st.st_dev; }; return sizeVec;