-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 poll notify #14670
Open
jlaitine
wants to merge
3
commits into
apache:master
Choose a base branch
from
tiiuae:fix_poll_notify
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix poll notify #14670
+39
−49
Conversation
This file contains 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
github-actions
bot
added
Area: Drivers
Drivers issues
Area: File System
File System issues
Size: S
The size of the change in this PR is small
labels
Nov 6, 2024
[Experimental Bot, please feedback here] Yes, this PR mostly meets the NuttX requirements, although some clarifications and additions are needed. Missing/Needs Improvement:
Recommendations:
By addressing these points, you will significantly improve the quality of your PR and make it easier for reviewers to understand and accept your changes. |
pollfd revents value is occasionally zeroed by race condition when poll_notify() is called. This results to false timeout return value from poll(). This behavior was found out when application called tcdrain() before calling uart poll(). Signed-off-by: Tero Salminen <[email protected]>
…events This is an optimization. Signed-off-by: Jukka Laitinen <[email protected]>
This reverts commit bbb7f43.
jlaitine
force-pushed
the
fix_poll_notify
branch
from
November 8, 2024 07:09
7dfa67d
to
bf584e9
Compare
re-based to current master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area: Drivers
Drivers issues
Area: File System
File System issues
Size: S
The size of the change in this PR is small
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.
Summary
Fix a race condition in poll_notify, revert seemingly unnecessary change in serial driver.
Originally, the race condition was found with an older nuttx version inside the poll_notify, and the same race condition exists also in the current upstream version.
This PR has the first patch, which protects from the RMW issue. Second patch is an optimization to the poll_notify, but also fixes another race which may cause callback being called twice.
For the serial driver, the issue has been circumvented in #13914, but the race condition should be fixed in poll_notify, as it exists for all the poll interfaces, and not just serial driver. I believe that the serial driver fix is unnecessary, so third patch is reverting that - it is not nice to add sched_locks around the drivers unnecessarily.
Impact
Impacts the implementation of poll / poll_notify, fixing a read-modify-write race condition.
Testing
The code has been inspected by 2 engineers, and desk-tested with real application using the poll interface. However, I don't have a possibility to run extensive testing which would show the exact issue which was fixed in #13914, so I'd appreciate if the solution is reviewed & tested by e.g. @CV-Bowen who fixed the race condition for serial driver.