-
Notifications
You must be signed in to change notification settings - Fork 238
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
Eventfd with epoll EPOLLET event doesn't match Linux #2673
Comments
TCP sockets seem to be the same https://github.com/ppopth/tcp_epoll_shadow |
Thanks for the bug report! So I think this comes down to the question "what is an edge?" with respect to Linux files. Shadow uses the definition "the file was not readable/writable, and has now become readable/writable". It seems that this is the definition that was originally intended for Linux, but some files would wake the edge-triggered epoll even when it already had data, so programmers started relying on this unintended behaviour.
https://lwn.net/ml/linux-kernel/CAHk-=witY33b-vqqp=ApqyoFDpx9p+n4PwG9N-TvF8bq7-tsHw@mail.gmail.com/ Since Shadow uses this "there was no data, now there is data" definition for an edge, it doesn't wake the second It seems that the WSL also originally took this same approach as Shadow: microsoft/WSL#2462. There's also a LWN article about this: https://lwn.net/Articles/864947/ We should probably change Shadow to follow the Linux behaviour here, even if it's not "correct". The issue is that Shadow's status listeners don't have a way of listening for "READABLE" -> "READABLE" status changes, so this might be tricky to fix. |
Do you have a real-world application that depends on this behaviour? We discussed this today, and while we probably do want to make these changes, they're not currently high on our priority list. This is probably something we'd look at when migrating our There is a possible downside to making this change. Waking up the |
I encountered this while running the command
I think the most important thing is the intention of the application developers, i.e. how the developers want the applications to behave. What the developers usually do when they write the applications is they have to test them against the machines which most of the time are Linux. If the machines don't behave correctly and then make the application behave incorrectly, they just change the application to be consistent with the machine. I think "doing the right thing" is the right thing to do, if the developers (or we encourage them to) test the applications against both Linux and Shadow. If so, we can keep doing the right thing because the applications will behave correctly in Shadow anyway. But if the developers test the applications only against Linux (and we will assume it will be that way forever), there is a good chance that the applications will not behave correctly in Shadow (and the intention mentioned above is violated) if Shadow behaves differently from Linux.
I don't think it will cause worse performance. I think only when the managed process will waken up more often is when the managed process already knows there is data but still epolls the fd. This doesn't quite make sense to me. Why does the managed process need to epoll the fd while it can just read the data? The only answer I can think of is that "the managed process doesn't want to read the data". It probably just wants to get notified when there is more data. This will reduce the number of syscalls the process needs to make (by calling only epoll_wait). In my opinion, I will conclude that applications that don't rely on this Linux-specific behavior will not epoll the fd while they already know there is data anyway, so there will be no penalty. PS> However, I decided to patch Shadow to make it similar to Linux myself anyway. Because I think it's quite easier for me to patch Shadow than to patch the application and I also have a plan to use Shadow with many more applications. I think it's quite convenient for me not to think whether this behavior will be an issue again. |
This should be fixed by #3243. |
Describe the issue
When using eventfd with epoll with EPOLLET flag set, the result of epoll_wait in the real Linux is different from the one in Shadow
To Reproduce
Run the following code in Linux and in Shadow and see the difference.
In Linux, the output will be
But in Shadow, the output is
Operating System (please complete the following information):
Shadow (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: