RDKB-64487: Code changes for Mutex locking and deadlock prevention#334
Open
AravindanNC wants to merge 7 commits intodevelopfrom
Open
RDKB-64487: Code changes for Mutex locking and deadlock prevention#334AravindanNC wants to merge 7 commits intodevelopfrom
AravindanNC wants to merge 7 commits intodevelopfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors locking in the bulkdata profile and XConf profile implementations to reduce contention and prevent deadlocks by moving from a single global mutex to more structured locking (rwlock for the profile list, dedicated mutex for XConf), and by documenting an intended lock hierarchy.
Changes:
- Replaced the global profile list mutex with
profileListLock(pthread_rwlock_t) and updated call sites. - Introduced a documented lock hierarchy and added a per-profile
profileMutexfield. - Renamed XConf’s global mutex to
xconfProfileLockand updated the XConf thread/condition-variable synchronization to use it.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| source/bulkdata/profilexconf.c | Renames and re-scopes XConf locking to xconfProfileLock and updates the report thread synchronization logic. |
| source/bulkdata/profile.h | Documents a lock hierarchy and adds profileMutex to Profile. |
| source/bulkdata/profile.c | Migrates from a single mutex to profileListLock (rwlock) and updates many code paths accordingly. |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
source/bulkdata/profilexconf.c:243
reportInProgressis written underxconfProfileLockinCollectAndReportXconf()(e.g.,profile->reportInProgress = true;) but read undersingleProfile->reportInProgressMutexinProfileXConf_uninit()andProfileXConf_notifyTimeout(). Using different mutexes to guard the same flag breaks synchronization and can introduce data races (especiallyProfileXConf_uninit()which does not holdxconfProfileLockwhen reading). Please makereportInProgressconsistently protected by a single lock (ideally the same mutex used withreuseThread’s condition variable) and update all accesses accordingly.
/* Set reportInProgress flag to prevent concurrent report generation
* and profile deletion while we're working. This must be done under
* xconfProfileLock to prevent races with ProfileXConf_notifyTimeout() and
* ProfileXConf_delete().
*/
profile->reportInProgress = true;
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.
Reason for change: Replace global plMutex with per-profile lookup optimization. Add deadlock prevention by lock hierarchy enforcement.
Test Procedure: Build RDKE image
Signed-off-by: nc.aravindan@gmail.com