Repository navigation
time: un-shift absolute deadlines only on the wall clock #359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
congwang-mk
merged 3 commits into
multikernel:main
from
saviourmk:time-abstime-deadlines
Nov 30, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rewrites the caller's timespec in place, so a reused deadline is un-shifted twice. A periodic loop (
ts.tv_sec += 1; clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &ts, NULL)) or an EINTR retry with the sametssleeps for decades on the second call. Pre-existing, but this PR makes it reachable for realtimeclock_nanosleep. Could you restore the original value after the syscall (or keep the rewrite out of the child's view), and add a second iteration reusing the struct to the test?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks. Restoring it after the syscall doesn't work with Continue, since the supervisor never sees the call come back, and writing the old value back right after the response would race the kernel's read. So I went the other way in bf364c2: for an absolute CLOCK_REALTIME clock_nanosleep the timespec is only read, and the supervisor sleeps until the real deadline in a patient deferral (like the FIFO open wait) and answers 0. Because WAIT_KILLABLE_RECV holds signals until the notification is answered, it checks every 20ms for a pending signal the thread doesn't block and answers EINTR, and it stops when the notification id goes invalid. One difference is that the wakeup goes through the tokio timer, so it's millisecond rather than microsecond precise.
The test now sleeps twice reusing the same struct, and also retries with the same struct after an EINTR. The reuse case hangs until the 30s guard on the previous commit, and the EINTR case fails without the signal check.
timerfd_settime and timer_settime still adjust the itimerspec in place, so reusing one there has the same problem. The timerfd one could be set on the child's behalf through pidfd_getfd, POSIX timers can't, so I left both as they were. Happy to do the timerfd part here or in a follow-up if you want it.