Expanded support for musl/linux syscalls (sysinfo, getrusage, prlimit64, umask, fchmodat) - #183
Merged
Merged
Conversation
…ries Programs that size their working memory from sysconf(_SC_PHYS_PAGES), compilers and language runtimes among them, reach the kernel through sysinfo. The handler reports uptime from the monotonic clock, memory from the pmm page counters, and the task count from the registry, with the swap and load fields zeroed since no such accounting exists.
Toolchain programs collect timing statistics through getrusage and read the result structure even when the call fails, which reported uninitialized stack memory as timings. CPU time now comes from the per-task run tick counters, summed across the task group for RUSAGE_SELF, with all time reported as user time since no user versus kernel split is accounted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Low Risk
Additive syscall and per-process metadata with stub chmod/umask behavior; prlimit limits are stored but not newly enforced on open/stack paths in this diff.
Overview
Adds several Linux/musl-facing syscalls and wires them into the aarch64/x86_64 syscall number tables and
syscall_table.cpp.Process state: Each
thread_groupnow holds per-process resource limits (rlimits) and a umask. New processes inherit both from the creator (POSIX-style) or get defaults (init_default_rlimits, umask022).prlimit64reads/writes limits for the caller’s PID only (with validation);umaskatomically swaps the mask under the group lock.Reporting syscalls:
sysinfofills uptime, RAM totals/free from the PMM, and a live process count.getrusagereturns mostly-zerorusageexcept CPU time fromrun_ticks(all counted as user time; children are zero).Permission stubs:
fchmodat/ x86chmodresolve the path like other*athandlers and succeed without changing modes (VFS has no stored mode bits). Same pattern as existingfaccessatstubs.Kernel unit tests cover EINVAL/EFAULT/ESRCH edge cases; fuller behavior is left to userland.
Reviewed by Cursor Bugbot for commit 27acf54. Bugbot is set up for automated code reviews on this repo. Configure here.