fix(utils): honour EFD_NONBLOCK when combined with EFD_SEMAPHORE on macOS - #116
Open
ya-luotao wants to merge 1 commit into
Open
fix(utils): honour EFD_NONBLOCK when combined with EFD_SEMAPHORE on macOS#116ya-luotao wants to merge 1 commit into
ya-luotao wants to merge 1 commit into
Conversation
…acOS The pipe-based eventfd emulation only set O_NONBLOCK when the flags were exactly EFD_NONBLOCK. pollable_channel creates its eventfd with EFD_NONBLOCK | EFD_SEMAPHORE, so the pipe stayed blocking and the first consumer to drain the channel (the virtio-input worker's second next_event call) blocked forever; no input event ever reached the guest on macOS. Test the bit instead of the whole value.
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.
Bug
EventFd::newin the macOS pipe-based emulation only setsO_NONBLOCKwhenflag == EFD_NONBLOCK.pollable_channelcreates its eventfd withEFD_NONBLOCK | EFD_SEMAPHORE, so the pipe stays blocking.Consequence: any consumer that drains a
PollableChannelRecieveruntil empty blocks on the read of the empty pipe. The virtio-input worker does exactly that (fill_event_virtqueuecallsnext_event()until it returnsNone), so on macOS the worker hung on the secondnext_event()of the first batch and no input event ever reached the guest. Nothing is logged; the device just never delivers.Fix
Test the
EFD_NONBLOCKbit instead of comparing the whole flag value (one line).Verification
microsandbox on Apple Silicon (HVF) with the
inputfeature, an Arch Linux ARM guest running Hyprland: before the change, evdev events pushed through apollable_channelnever showed up on/dev/input/event*; after it, libinput sees the keyboard and pointer and Super+K opens Omarchy's cheatsheet. Blk/net/vsock (which also useEventFd) keep working in the same build. Write-up: https://github.com/ya-luotao/msb-omarchy/blob/main/docs/assessment.md🤖 Generated with Claude Code
https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ