From c0758220038a203c1af3c789d3a3e4815d249a3c Mon Sep 17 00:00:00 2001 From: DH Date: Fri, 22 Nov 2024 14:49:57 +0300 Subject: [PATCH] kernel: sysctl: add vm.budgets.avail --- orbis-kernel/src/sys/sys_sysctl.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/orbis-kernel/src/sys/sys_sysctl.cpp b/orbis-kernel/src/sys/sys_sysctl.cpp index ca57fbe..7cf9255 100644 --- a/orbis-kernel/src/sys/sys_sysctl.cpp +++ b/orbis-kernel/src/sys/sys_sysctl.cpp @@ -76,6 +76,7 @@ SysResult kern_sysctl(Thread *thread, ptr name, uint namelen, enum sysctl_vm_budgets_ { mlock_total = 1000, + mlock_avail = 1000, }; struct ProcInfo { @@ -193,6 +194,19 @@ SysResult kern_sysctl(Thread *thread, ptr name, uint namelen, *(uint64_t *)old = 5056ull * 1024 * 1024; return {}; } + + + if (name[0] == vm && name[1] == budgets && name[2] == mlock_avail) { + if (*oldlenp != 16 || new_ != nullptr || newlen != 0) { + return ErrorCode::INVAL; + } + + // TODO + auto result = (uint64_t *)old; + result[0] = 0; + result[1] = 5056ull * 1024 * 1024; + return {}; + } } if (namelen >= 3) { @@ -539,6 +553,15 @@ SysResult kern_sysctl(Thread *thread, ptr name, uint namelen, dest[count++] = vm; dest[count++] = budgets; dest[count++] = mlock_total; + } else if (searchName == "vm.budgets.mlock_avail") { + if (*oldlenp < 3 * sizeof(uint32_t)) { + std::fprintf(stderr, " %s error\n", searchName.data()); + return ErrorCode::INVAL; + } + + dest[count++] = vm; + dest[count++] = budgets; + dest[count++] = mlock_avail; } if (count == 0) {