[CLR][NFCI] Refactor the unique file descriptor management#4264
Draft
steffenlarsen wants to merge 1 commit intodevelopfrom
Draft
[CLR][NFCI] Refactor the unique file descriptor management#4264steffenlarsen wants to merge 1 commit intodevelopfrom
steffenlarsen wants to merge 1 commit intodevelopfrom
Conversation
This commit changes the management of unique file descriptors for fat binary files. The main change is that the `PlatformState` class now now contains a map of weak pointers to the unique file descriptor and the individual file descriptors manage their own lifetime by calling back into the `PlatformState` when they are destroyed. This allows the implementation to not rely on the user count of the shared pointers, which are only considered accurate when they are 0 (as there could be new shared pointers being created at the same time as others are being destroyed). In addition to this, the image management inside the `FatBinary` class has been moved to the new `ManagedUniqueFD` struct, which is now in charge of unmapping the image if it was mapped. Signed-off-by: Steffen Holst Larsen <sholstla@amd.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
The tracking and management of unique file descriptors for fatbin files currently uses
std::shared_ptrbut relies onuse_count()which is considered imprecise as new uses can be created between reads. To amend this, the implementation can directly utilize the smart pointers to have them clean up descriptors themselves.Technical Details
This patch changes the management of unique file descriptors for fat binary files. The main change is that the
PlatformStateclass now now contains a map of weak pointers to the unique file descriptor and the individual file descriptors manage their own lifetime by calling back into thePlatformStatewhen they are destroyed. This allows the implementation to not rely on the user count of the shared pointers, which are only considered accurate when they are 0 (as there could be new shared pointers being created at the same time as others are being destroyed).In addition to this, the image management inside the
FatBinaryclass has been moved to the newManagedUniqueFDstruct, which is now in charge of unmapping the image if it was mapped.JIRA ID
N/A
Test Plan
No functional changes are intended with this, so current testing should be sufficient.
Test Result
No functional changes are intended with this, so current testing should be sufficient.
Submission Checklist