You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2020/05/20 23:22:54 UTC

[mesos] branch master updated (220935a -> 5a04a16)

This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.


    from 220935a  Added MESOS-10128 to the 1.10.0 CHANGELOG.
     new c966e89  Fixed FreeBSD memory detection.
     new 5a04a16  Added a test for os::memory.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 3rdparty/stout/include/stout/os/freebsd.hpp | 26 +++++++++++++++++++-------
 3rdparty/stout/tests/os_tests.cpp           | 17 +++++++++++++++++
 2 files changed, 36 insertions(+), 7 deletions(-)


[mesos] 02/02: Added a test for os::memory.

Posted by bm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 5a04a1693e4f1d51007c23728f1884a307e229a1
Author: James Wright <ja...@digital-chaos.com>
AuthorDate: Wed May 20 19:21:54 2020 -0400

    Added a test for os::memory.
---
 3rdparty/stout/tests/os_tests.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/3rdparty/stout/tests/os_tests.cpp b/3rdparty/stout/tests/os_tests.cpp
index 4231303..6b04181 100644
--- a/3rdparty/stout/tests/os_tests.cpp
+++ b/3rdparty/stout/tests/os_tests.cpp
@@ -1289,3 +1289,20 @@ TEST_F(OsTest, Which)
   which = os::which("bar");
   EXPECT_NONE(which);
 }
+
+
+TEST_F(OsTest, Memory)
+{
+  Try<os::Memory> memory = os::memory();
+  ASSERT_SOME(memory);
+
+  // Verify total memory is greater than zero.
+  EXPECT_GT(memory->total, 0);
+
+  // Verify free memory is greater than zero and less than total.
+  EXPECT_GT(memory->free, 0);
+  EXPECT_LT(memory->free, memory->total);
+
+  // Verify freeSwap is less than or equal to totalSwap (both can be zero)
+  EXPECT_LE(memory->freeSwap, memory->totalSwap);
+}


[mesos] 01/02: Fixed FreeBSD memory detection.

Posted by bm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit c966e89e967a5c55a79646037614521a1c1c8557
Author: James Wright <ja...@digital-chaos.com>
AuthorDate: Wed May 20 19:20:39 2020 -0400

    Fixed FreeBSD memory detection.
    
    See MESOS-10104.
    
    This closes #365
---
 3rdparty/stout/include/stout/os/freebsd.hpp | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/3rdparty/stout/include/stout/os/freebsd.hpp b/3rdparty/stout/include/stout/os/freebsd.hpp
index f807848..bd8da53 100644
--- a/3rdparty/stout/include/stout/os/freebsd.hpp
+++ b/3rdparty/stout/include/stout/os/freebsd.hpp
@@ -88,17 +88,28 @@ inline Try<Memory> memory()
   const size_t pageSize = os::pagesize();
 
   unsigned int freeCount;
-  size_t length = sizeof(freeCount);
-
+  size_t freeCountLength = sizeof(freeCount);
   if (sysctlbyname(
-      "vm.stats.v_free_count",
+      "vm.stats.vm.v_free_count",
       &freeCount,
-      &length,
+      &freeCountLength,
       nullptr,
       0) != 0) {
     return ErrnoError();
   }
-  memory.free = Bytes(freeCount * pageSize);
+
+  unsigned int inactiveCount;
+  size_t inactiveCountLength = sizeof(inactiveCount);
+  if (sysctlbyname(
+      "vm.stats.vm.v_inactive_count",
+      &inactiveCount,
+      &inactiveCountLength,
+      nullptr,
+      0) != 0) {
+    return ErrnoError();
+  }
+
+  memory.free = Bytes((freeCount + inactiveCount) * pageSize);
 
   int totalBlocks = 0;
   int usedBlocks = 0;
@@ -112,8 +123,9 @@ inline Try<Memory> memory()
   // FreeBSD supports multiple swap devices. Here we sum across all of them.
   struct xswdev xswd;
   size_t xswdSize = sizeof(xswd);
-  int* mibDevice = &(mib[mibSize + 1]);
-  for (*mibDevice = 0; ; (*mibDevice)++) {
+  for (int ndev = 0; ; ndev++) {
+      mib[mibSize] = ndev;
+
       if (::sysctl(mib, 3, &xswd, &xswdSize, nullptr, 0) != 0) {
           if (errno == ENOENT) {
               break;