Skip to content

Add epoll integration for network sockets#4973

Open
WhySoBad wants to merge 8 commits intorust-lang:masterfrom
WhySoBad:network-socket-epoll-new
Open

Add epoll integration for network sockets#4973
WhySoBad wants to merge 8 commits intorust-lang:masterfrom
WhySoBad:network-socket-epoll-new

Conversation

@WhySoBad
Copy link
Copy Markdown
Contributor

Hi,

This pull request adds integration for Miri's epoll shim to the TCP socket shim.

Due to the platform specific differences of mio's poll, the blocking I/O manager had to be refactored to a high degree. Instead of having sources only registered in the poll when we're currently interested in an event, we now have the sources registered in the poll with all available interests for their entire lifespan. We now also store the current readiness for every source in the blocking I/O manager.
When for example a thread should be blocked until some I/O interest is fulfilled on a source, we just add the receiver to the blocking I/O manager without changing anything in the poll itself. In every call to poll we now return all interest receivers whose interests are currently fulfilled -- no longer only those which are newly fulfilled.
Once we hit an EWOULDBLOCK in a source operation (e.g. read, write, accept, ...) we need to falsify the corresponding readiness in the blocking I/O manager to keep it up to date.

With this refactor, the actual epoll implementation is pretty straightforward -- we just need to return the readiness stored in the blocking I/O manager from the epoll_active_events method of host-backed source file descriptions.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 20, 2026

Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two.
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Apr 20, 2026
@rustbot

This comment has been minimized.

@WhySoBad WhySoBad force-pushed the network-socket-epoll-new branch from 6d96f3e to db7c84b Compare April 23, 2026 13:08
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 23, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@RalfJung
Copy link
Copy Markdown
Member

Feedback was given IRL.
@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Waiting for a review to complete label Apr 27, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 27, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Apr 27, 2026
@WhySoBad
Copy link
Copy Markdown
Contributor Author

I noticed that I wrote the review comments of today's meeting in the PR on my fork, but every of those comments should now be resolved anyways.

The BlockingIoManager:poll now updates the epoll readiness of all sources. I've still kept the InterestReceivers even though we only need it for unblocking threads at the moment (maybe there will be something in the future which also needs to be added to the blocking I/O manager).
I've also renamed the EpollEvents struct to EpollReadiness. This is more in line with the new BlockingIoSourceReadiness struct of the blocking I/O manager.

Also, as you requested, the epoll test cases should now fail/block indefinitely when we forget to register a socket or when we forget to remove the readiness after receiving EWOULDBLOCK.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Waiting for a review to complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants