kernel: sysctl: add vm.budgets.avail

This commit is contained in:
DH 2024-11-22 14:49:57 +03:00
parent 8797cf8475
commit c075822003

View File

@ -76,6 +76,7 @@ SysResult kern_sysctl(Thread *thread, ptr<sint> 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<sint> 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<sint> 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) {