ignore non-existent mount points in readHugePageSizes
authorPhilip Pronin <philipp@fb.com>
Mon, 5 May 2014 17:10:41 +0000 (10:10 -0700)
committerDave Watson <davejwatson@fb.com>
Tue, 20 May 2014 19:53:57 +0000 (12:53 -0700)
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

folly/experimental/io/HugePages.cpp

index d18167fdd416cbd6d7c77cdd509db2fbfb9fb2fa..5b4a0706a66bb1cddebcd15936e05adfb6b9356b 100644 (file)
@@ -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;