Conversation
xalestar
force-pushed
the
fix-select-epoll-signal-wake
branch
from
September 16, 2026 08:16
526a2d7 to
3b03f71
Compare
There was a problem hiding this comment.
Review completed against the latest diff
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
A thread parked in a host wait learns of a guest signal only through the wakeup pipe. pselect6 joined the pipe for an indefinite wait alone, and epoll_pwait never did, so a queued signal sat out the rest of the 200 ms slice before the handler ran. pselect6 now joins the pipe for every wait but a zero timeout, which does not park and would only drain a wake meant for a sibling. epoll_pwait parks in poll() on the kqueue fd and the pipe, then collects with a zero-timeout kevent(). Registering the pipe on the kqueue itself would put a host fd on the guest's epoll instance. tests/test-wait-signal-latency.c measures signal-to-handler delay for a finite select and for finite and indefinite epoll_wait. On main the median is about 42 ms for each; with this change all three are under the 20 ms bound. futex has the same defect and is left for a separate change. Refs sysprog21#378
xalestar
force-pushed
the
fix-select-epoll-signal-wake
branch
from
September 16, 2026 08:36
3b03f71 to
3b9c809
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.
Part of #378; futex is left for after #383.
A thread parked in a host wait learns of a guest signal only through the wakeup pipe. pselect6 joined the pipe for an indefinite wait only, and epoll_pwait never did, so the handler ran only once the current 200 ms slice ended.
pselect6 now joins the pipe for every wait except a zero timeout, which does not park and would only drain a wake meant for a sibling. epoll_pwait parks in poll() on the kqueue fd plus the pipe, then collects with a zero-timeout kevent(), so the pipe is never registered on the guest's epoll instance.
Reproduction:
tests/test-wait-signal-latency.cparks a sibling thread in each wait on an empty pipe, sends SIGUSR1 with pthread_kill, and takes the median signal-to-handler gap over 8 rounds against a 20 ms bound. On0a63368all three cases fail at about 42 ms (select with a timeout, epoll_wait with and without one); with this change all three pass.Validation, rebased on
0a63368:make check: exit 0test-wait-signal-latency,test-wait-process-signal,test-wait-sigmask-signal,test-nanosleep-signal-latency: passmake test-matrix-elfuse-aarch64: 291 passed, 1 failed, 10 skipped. The failure istest-sigio(no SIGURG on a TCP OOB byte). It also fails 3/3 on0a63368and does not touch select or epoll.Summary by cubic
Wakes threads parked in
select/pselect6andepoll_wait/epoll_pwaitimmediately when a guest signal is queued, instead of letting the handler wait out the rest of the 200 ms slice.pselect6now joins the wakeup pipe on every wait except a zero-timeout poll, which does not park.epoll_pwaitnow parks inpoll()on the kqueue fd plus the pipe, then collects with a zero-timeoutkevent(), so the pipe never shows up on the guest's epoll instance.tests/test-wait-signal-latency.cto measure signal-to-handler latency for finite and indefinite waits.Written for commit 3b9c809. Summary will update on new commits.