-
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
using rwsem lock as inode_lock to avoid deadlock #13736
Conversation
[Experimental Bot, please feedback here] Let's analyze if this Pull Request (PR) description fulfills the NuttX requirements: Strengths:
Weaknesses:
Verdict & Recommendations: This PR description is a good starting point but does not fully meet NuttX requirements. Here's how to improve it:
By addressing these points, you'll create a more robust and informative PR description, increasing the likelihood of a smoother review and acceptance. |
Signed-off-by: dongjiuzhu1 <[email protected]>
Signed-off-by: dongjiuzhu1 <[email protected]>
return ret; | ||
} | ||
|
||
inode_lock(); |
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.
inode_rlock
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.
In some scenarios, inode_find and inode_remove are used in combination, such as in shm_open and shm_unlink. The remove operation requires a write lock. If we were to switch to a read lock in inode_find, then a lock would need to be added in inode_remove, and additional checks would be required elsewhere.
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.
let's create a patch to change rwsem which promote rlock to wlock if the same thread already hold wlock.
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.
#13797 Done~
Example: When executing "df -h" on Core A to view mount information, this process will traverse inode nodes, thereby holding the inode_lock. Since the inode type of the mount point may be rpmsgfs, it will fetch statfs information from another Core B. Meanwhile, rcS on Core B needs to obtain file information from Core A, which will be achieved by fetching stat information through rpmsgfs. When this message arrives at Core A, a deadlock can occur between Core A's rptun ap and nsh task. However, both of these places involve read operations only, thus a reader-writer lock can be utilized to prevent such a deadlock. Signed-off-by: dongjiuzhu1 <[email protected]>
Signed-off-by: dongjiuzhu1 <[email protected]>
Summary
deadlock examples:
When executing df -h on Core A to view mount information, this process will traverse inode nodes, thereby holding the inode_lock. Since the inode type of the mount point may be rpmsgfs, it will fetch staffs information from another Core B.
Meanwhile, rcS on Core B needs to obtain file information from Core A, which will be achieved by fetching stat information through rpmsgfs. When this message arrives at Core A, a deadlock can occur between Core A's rptun ap and nsh task.
However, both of these places involve read operations only, thus a reader-writer lock can be utilized to prevent such a deadlock.
Impact
Bug fix
Testing
Vela