You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2016/04/12 23:11:25 UTC

[1/2] mesos git commit: Stout: Transitioned codebase to use `os::pagesize`.

Repository: mesos
Updated Branches:
  refs/heads/master 25a4ecb5c -> 2e76199a3


Stout: Transitioned codebase to use `os::pagesize`.

Review: https://reviews.apache.org/r/45943/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a170204b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a170204b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a170204b

Branch: refs/heads/master
Commit: a170204b4931a5b0bcfc83d185c182430b5f43a9
Parents: 25a4ecb
Author: Alex Clemmer <cl...@gmail.com>
Authored: Tue Apr 12 13:35:25 2016 -0700
Committer: Michael Park <mp...@apache.org>
Committed: Tue Apr 12 13:41:29 2016 -0700

----------------------------------------------------------------------
 .../3rdparty/stout/include/Makefile.am          |  3 ++
 .../3rdparty/stout/include/stout/os.hpp         |  1 +
 .../3rdparty/stout/include/stout/os/freebsd.hpp |  5 ++--
 .../3rdparty/stout/include/stout/os/linux.hpp   |  6 ++--
 .../3rdparty/stout/include/stout/os/osx.hpp     |  3 +-
 .../stout/include/stout/os/pagesize.hpp         | 26 +++++++++++++++++
 .../stout/include/stout/os/posix/pagesize.hpp   | 30 ++++++++++++++++++++
 .../stout/include/stout/os/windows/pagesize.hpp | 30 ++++++++++++++++++++
 .../3rdparty/stout/include/stout/posix/os.hpp   |  8 ------
 .../3rdparty/stout/include/stout/windows/os.hpp |  8 ------
 10 files changed, 98 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a170204b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
index f92871b..33ddb06 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -80,6 +80,7 @@ nobase_include_HEADERS =			\
   stout/os/open.hpp				\
   stout/os/os.hpp				\
   stout/os/osx.hpp				\
+  stout/os/pagesize.hpp			\
   stout/os/permissions.hpp			\
   stout/os/process.hpp				\
   stout/os/pstree.hpp				\
@@ -110,6 +111,7 @@ nobase_include_HEADERS =			\
   stout/os/posix/ftruncate.hpp			\
   stout/os/posix/killtree.hpp			\
   stout/os/posix/mkdtemp.hpp			\
+  stout/os/posix/pagesize.hpp			\
   stout/os/posix/pstree.hpp			\
   stout/os/posix/read.hpp			\
   stout/os/posix/rename.hpp			\
@@ -133,6 +135,7 @@ nobase_include_HEADERS =			\
   stout/os/windows/ftruncate.hpp		\
   stout/os/windows/killtree.hpp			\
   stout/os/windows/mkdtemp.hpp			\
+  stout/os/windows/pagesize.hpp		\
   stout/os/windows/pstree.hpp			\
   stout/os/windows/read.hpp			\
   stout/os/windows/rename.hpp			\

http://git-wip-us.apache.org/repos/asf/mesos/blob/a170204b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
index e7accaa..a810868 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -51,6 +51,7 @@
 #include <stout/os/mkdir.hpp>
 #include <stout/os/mkdtemp.hpp>
 #include <stout/os/mktemp.hpp>
+#include <stout/os/pagesize.hpp>
 #include <stout/os/process.hpp>
 #include <stout/os/rename.hpp>
 #include <stout/os/rm.hpp>

http://git-wip-us.apache.org/repos/asf/mesos/blob/a170204b/3rdparty/libprocess/3rdparty/stout/include/stout/os/freebsd.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/freebsd.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/freebsd.hpp
index 6b81bf1..ce4e4cc 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/freebsd.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/freebsd.hpp
@@ -22,6 +22,7 @@
 #include <sys/user.h>
 #include <unistd.h>
 
+#include <stout/os/pagesize.hpp>
 #include <stout/os/sysctl.hpp>
 
 namespace os {
@@ -41,7 +42,7 @@ inline Result<Process> process(pid_t pid)
 
   foreach (const kinfo_proc& kinfo, kinfos.get()) {
     if (kinfo.ki_pid == pid) {
-      int pagesize = getpagesize();
+      int pagesize = os::pagesize();
       return Process(kinfo.ki_pid,
                      kinfo.ki_ppid,
                      kinfo.ki_pgid,
@@ -83,7 +84,7 @@ inline Try<Memory> memory()
   }
   memory.total = Bytes(physicalMemory.get());
 
-  const int pageSize = getpagesize();
+  const int pageSize = os::pagesize();
 
   unsigned int freeCount;
   size_t length = sizeof(freeCount);

http://git-wip-us.apache.org/repos/asf/mesos/blob/a170204b/3rdparty/libprocess/3rdparty/stout/include/stout/os/linux.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/linux.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/linux.hpp
index 182ac9c..3382528 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/linux.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/linux.hpp
@@ -33,6 +33,7 @@
 #include <stout/result.hpp>
 #include <stout/try.hpp>
 
+#include <stout/os/pagesize.hpp>
 #include <stout/os/process.hpp>
 
 namespace os {
@@ -83,10 +84,9 @@ inline pid_t clone(const lambda::function<int()>& func, int flags)
 inline Result<Process> process(pid_t pid)
 {
   // Page size, used for memory accounting.
-  // NOTE: This is more portable than using getpagesize().
-  static const long pageSize = sysconf(_SC_PAGESIZE);
+  static const int pageSize = os::pagesize();
   if (pageSize <= 0) {
-    return Error("Failed to get sysconf(_SC_PAGESIZE)");
+    return Error("Failed to get `os::pagesize`");
   }
 
   // Number of clock ticks per second, used for cpu accounting.

http://git-wip-us.apache.org/repos/asf/mesos/blob/a170204b/3rdparty/libprocess/3rdparty/stout/include/stout/os/osx.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/osx.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/osx.hpp
index 692fa48..a801092 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/osx.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/osx.hpp
@@ -32,6 +32,7 @@
 #include <stout/none.hpp>
 #include <stout/strings.hpp>
 
+#include <stout/os/pagesize.hpp>
 #include <stout/os/process.hpp>
 #include <stout/os/sysctl.hpp>
 
@@ -202,7 +203,7 @@ inline Try<Memory> memory()
 
   // Size of free memory is available in terms of number of
   // free pages on Mac OS X.
-  const long pageSize = sysconf(_SC_PAGESIZE);
+  const int pageSize = os::pagesize();
   if (pageSize < 0) {
     return ErrnoError();
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/a170204b/3rdparty/libprocess/3rdparty/stout/include/stout/os/pagesize.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/pagesize.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/pagesize.hpp
new file mode 100644
index 0000000..f46da55
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/pagesize.hpp
@@ -0,0 +1,26 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_PAGESIZE_HPP__
+#define __STOUT_OS_PAGESIZE_HPP__
+
+
+// For readability, we minimize the number of #ifdef blocks in the code by
+// splitting platform specifc system calls into separate directories.
+#ifdef __WINDOWS__
+#include <stout/os/windows/pagesize.hpp>
+#else
+#include <stout/os/posix/pagesize.hpp>
+#endif // __WINDOWS__
+
+
+#endif // __STOUT_OS_PAGESIZE_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/a170204b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/pagesize.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/pagesize.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/pagesize.hpp
new file mode 100644
index 0000000..f3ae69a
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/pagesize.hpp
@@ -0,0 +1,30 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_POSIX_PAGESIZE_HPP__
+#define __STOUT_OS_POSIX_PAGESIZE_HPP__
+
+#include <unistd.h>
+
+
+namespace os {
+
+// The alternative `getpagesize()` does not exist when enforcing
+// strict POSIX compliance.
+inline int pagesize()
+{
+  return sysconf(_SC_PAGESIZE);
+}
+
+} // namespace os {
+
+#endif // __STOUT_OS_POSIX_PAGESIZE_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/a170204b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/pagesize.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/pagesize.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/pagesize.hpp
new file mode 100644
index 0000000..6112e97
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/pagesize.hpp
@@ -0,0 +1,30 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_WINDOWS_PAGESIZE_HPP__
+#define __STOUT_OS_WINDOWS_PAGESIZE_HPP__
+
+#include <stout/windows.hpp>
+
+
+namespace os {
+
+inline int pagesize()
+{
+  SYSTEM_INFO si;
+  GetSystemInfo(&si);
+  return si.dwPageSize;
+}
+
+} // namespace os {
+
+#endif // __STOUT_OS_WINDOWS_PAGESIZE_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/a170204b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
index e25d43b..52978f3 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
@@ -462,14 +462,6 @@ inline Try<std::set<pid_t> > children(pid_t pid, bool recursive = true)
   return children(pid, processes.get(), recursive);
 }
 
-
-// The alternative `getpagesize()` does not exist when enforcing
-// strict POSIX compliance.
-inline int pagesize()
-{
-  return sysconf(_SC_PAGESIZE);
-}
-
 /* /TODO */
 
 } // namespace os {

http://git-wip-us.apache.org/repos/asf/mesos/blob/a170204b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp
index c3f4faa..352ecc5 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp
@@ -38,14 +38,6 @@
 
 namespace os {
 
-inline int pagesize()
-{
-  SYSTEM_INFO si = {0};
-  GetSystemInfo(&si);
-  return si.dwPageSize;
-}
-
-
 // Sets the value associated with the specified key in the set of
 // environment variables.
 inline void setenv(


[2/2] mesos git commit: Containerizer: Transitioned codebase to use `os::pagesize`.

Posted by mp...@apache.org.
Containerizer: Transitioned codebase to use `os::pagesize`.

Review: https://reviews.apache.org/r/45944/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2e76199a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2e76199a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2e76199a

Branch: refs/heads/master
Commit: 2e76199a3dd977152110fbb474928873f31f7213
Parents: a170204
Author: Alex Clemmer <cl...@gmail.com>
Authored: Tue Apr 12 13:35:40 2016 -0700
Committer: Michael Park <mp...@apache.org>
Committed: Tue Apr 12 13:41:30 2016 -0700

----------------------------------------------------------------------
 src/examples/balloon_executor.cpp              | 4 +++-
 src/tests/containerizer/cgroups_tests.cpp      | 6 ++++--
 src/tests/containerizer/memory_test_helper.cpp | 4 +++-
 3 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2e76199a/src/examples/balloon_executor.cpp
----------------------------------------------------------------------
diff --git a/src/examples/balloon_executor.cpp b/src/examples/balloon_executor.cpp
index 3992184..108ebd9 100644
--- a/src/examples/balloon_executor.cpp
+++ b/src/examples/balloon_executor.cpp
@@ -31,6 +31,8 @@
 #include <stout/numify.hpp>
 #include <stout/os.hpp>
 
+#include <stout/os/pagesize.hpp>
+
 using namespace mesos;
 
 
@@ -50,7 +52,7 @@ static void balloon(size_t limit)
 
     // Allocate page-aligned virtual memory.
     void* buffer = NULL;
-    if (posix_memalign(&buffer, getpagesize(), chunk) != 0) {
+    if (posix_memalign(&buffer, os::pagesize(), chunk) != 0) {
       perror("Failed to allocate page-aligned memory, posix_memalign");
       abort();
     }

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e76199a/src/tests/containerizer/cgroups_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/cgroups_tests.cpp b/src/tests/containerizer/cgroups_tests.cpp
index ecd83c7..4cb3d61 100644
--- a/src/tests/containerizer/cgroups_tests.cpp
+++ b/src/tests/containerizer/cgroups_tests.cpp
@@ -48,6 +48,8 @@
 #include <stout/stringify.hpp>
 #include <stout/strings.hpp>
 
+#include <stout/os/pagesize.hpp>
+
 #include "linux/cgroups.hpp"
 #include "linux/perf.hpp"
 
@@ -1129,12 +1131,12 @@ TEST_F(CgroupsAnyHierarchyMemoryPressureTest, ROOT_IncreaseRSS)
 
   // Use a guard to error out if it's been too long.
   // TODO(chzhcn): Use a better way to set testing time limit.
-  uint64_t iterationLimit = (limit.bytes() / getpagesize()) * 10;
+  uint64_t iterationLimit = (limit.bytes() / os::pagesize()) * 10;
   uint64_t i = 0;
   bool stable = true;
   while (i < iterationLimit) {
     if (stable) {
-      EXPECT_SOME(helper.increaseRSS(getpagesize()));
+      EXPECT_SOME(helper.increaseRSS(os::pagesize()));
     }
 
     Future<uint64_t> _low = counters[Level::LOW]->value();

http://git-wip-us.apache.org/repos/asf/mesos/blob/2e76199a/src/tests/containerizer/memory_test_helper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/memory_test_helper.cpp b/src/tests/containerizer/memory_test_helper.cpp
index 92579a2..21c718d 100644
--- a/src/tests/containerizer/memory_test_helper.cpp
+++ b/src/tests/containerizer/memory_test_helper.cpp
@@ -35,6 +35,8 @@
 #include <stout/strings.hpp>
 #include <stout/try.hpp>
 
+#include <stout/os/pagesize.hpp>
+
 #include "tests/flags.hpp"
 #include "tests/utils.hpp"
 
@@ -84,7 +86,7 @@ static Try<void*> allocateRSS(const Bytes& size)
 #endif
 
   void* rss = NULL;
-  if (posix_memalign(&rss, getpagesize(), size.bytes()) != 0) {
+  if (posix_memalign(&rss, os::pagesize(), size.bytes()) != 0) {
     return ErrnoError("Failed to increase RSS memory, posix_memalign");
   }