-
Notifications
You must be signed in to change notification settings - Fork 201
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
[RFC] epoll-like PAL interface #1971
Comments
I am not convinced by this proposal. I think I understand the rationale, but here are my counter-arguments:
Also, regarding |
That bug was caused by a terrible design, where whether a file is trusted or allowed was stored implicitly, and obtained by looking at some other fields of the struct, and the default was "allowed". |
This issue was discussed in #1964, please see the comments there. TLDR: It was agreed to try to implement the EPOLLET emulation similar to the already-existing one, without adding the |
Description of the feature
I propose implementing a new set of PAL APIs for persistent host-side event collection. The new PAL APIs should, for the most part, directly follow
epoll_create/epoll_wait/epoll_ctl
design.The current
epoll
implementation in LibOS should be rewritten on top of these APIs, and so should the async thread.Arguably, the current
PalStreamsWaitEvents
API could be replaced with the new APIs, but it may still have the benefit of being more efficient for simple cases, so I am not proposing that.Why Gramine should implement it?
The reasons here are twofold: correctness and performance.
Currently, the implementation of
FIOASYNC
akaO_ASYNC
aka the async thread is just plain broken. Among other serious problems, it is written such that after runningFIOASYNC
, the application gets exactly oneSIGIO
when the underlying handle becomes ready, after which the handle is removed from the async thread's notification list. However, the correct semantics in this case require us to send anotherSIGIO
every time the underlying handle becomes ready again.I do not believe these semantics can be reasonably implemented with the current
PalStreamsWaitEvents
API. If we change the implementation of async thread to not remove the handle from the list, the semantics ofpoll
underlyingPalStreamsWaitEvents
will just cause the callback to be triggered again and again in a loop. We would need some mechanism to re-add the stream to the async thread's list when it becomes un-ready again, but we don't have anything like that.Having an
epoll
-based API in the PAL solves that — we can keep the set of allFIOASYNC
open handles persistently as anepoll
handle on the host side, usingEPOLLET
edge-triggered mode. Then we can just translate all incoming events directly intoSIGIO
. While I am not fully convinced the semantics are a perfect match (they go through distinct pathways in kernel source), I believe they are close enough for our purposes.The second reason has to do with the performance of our
epoll
implementation in LibOS — currently it is effectively emulated viapoll
, inheriting all of its problems.The text was updated successfully, but these errors were encountered: