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:55 UTC
[mesos] 01/02: Fixed FreeBSD memory detection.
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;