De-dup write_rusage_to_guest code#220
Merged
jserv merged 1 commit intoJul 18, 2026
Merged
Conversation
henrybear327
force-pushed
the
refactor/write_rusage_to_guest
branch
3 times, most recently
from
July 17, 2026 21:21
0410555 to
5a3b038
Compare
jserv
requested changes
Jul 17, 2026
jserv
left a comment
Contributor
There was a problem hiding this comment.
Enforce https://cbea.ms/git-commit/
sys_getrusage() open-coded the same macOS-to-Linux rusage translation that write_rusage_to_guest() already implements in proc.c for the ptrace paths: a whole-struct memcpy followed by ru_maxrss conversion from bytes to kilobytes. Carrying two copies risks them drifting apart, especially the layout assertions that gate the fast memcpy path. Expose the existing helper via proc.h and call it from sys_getrusage(), dropping the duplicate. Move the full-size _Static_assert next to the helper in proc.c; sys.c keeps only the ru_maxrss offset check that guards the translation done there.
henrybear327
force-pushed
the
refactor/write_rusage_to_guest
branch
from
July 18, 2026 14:31
5a3b038 to
874d928
Compare
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.
Stacked on #220
Summary by cubic
Deduplicated timespec validation/conversion and rusage write logic across syscalls to unify behavior and reduce drift. Ensures consistent EINVAL handling, overflow saturation, and getrusage translation.
linux_timespec_validandlinux_timespec_to_ns_sat; used inppoll,pselect6, andrt_sigtimedwait.write_rusage_to_guestviaproc.hand called it fromsys_getrusage; handlesru_maxrssbytes→KB conversion.write_rusage_to_guestinproc.c; kept only theru_maxrssoffset assert insys.cto guard the fast memcpy path.Written for commit 874d928. Summary will update on new commits.