-
Notifications
You must be signed in to change notification settings - Fork 682
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
fix: only close fanotify
events with a valid fd
#2399
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this behavior is in an official release, could you please add a changelog entry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. What about tests? Would it be possible to write a test that triggers a queue overflow?
Theoretically, yes. One can change the limit value of the queue length through file |
And is the original value impractically high to reach? |
Ahh, I think don't need to bother with that config file, the default value is 16384, it should be easy to reach it within 1-2 seconds with one thread repeatedly generating events |
Ok, I tried to write a test for this issue today, now I kinda think it is not possible to do that. We want the queue to be overflowed, so we have to trigger at least 16385 events, which should be easy with one thread looping reading files, however, Linux kernel would merge events that come from the same process (or thread if Then what about using 2 threads to make them access files alaternatively, then the events in the queue would theoretically be something like:
Well, this won't work either, Linux kernel will reorder and coalesce them. To not let Linux kernel merge events, we have 2 approaches:
|
Gentle ping on the PR author @tombl, do you have any idea on the test? :) |
I've also been struggling to write a test. I hit this behavior in my application that uses |
Yeah, I reproduced the overflow issue with 16385 threads, but can we stop Linux kernel from reusing thread IDs? |
I don't think it does reuse the thread IDs except when they overflow It should only be an issue if someone lowers their |
From this post, it indeed is, thanks for showing me this, TIL! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
What does this PR do
fanotify
returns events with the fd set toFAN_NOFD
when the queue overflows.Trying to close it panics with
EBADF
, so don't bother.Checklist:
CONTRIBUTING.md