Skip to content

Refactor backend-v4l::named_mutex - #14095

Merged
Nir-Az merged 4 commits into
realsenseai:developmentfrom
OhadMeir:linux_uvc
Jul 15, 2025
Merged

Nir-Az merged 4 commits into
realsenseai:developmentfrom
OhadMeir:linux_uvc

Conversation

@OhadMeir

Copy link
Copy Markdown
Contributor

Tracked on [RSDSO-20187]

named_mutex holding file descriptor (RAII).
Removed unnecessary locks and counters for file descriptor open/close.
Using atomic int as lock counter.

@OhadMeir
OhadMeir requested a review from Nir-Az June 23, 2025 18:48
@Nir-Az
Nir-Az requested a review from Copilot July 3, 2025 10:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Refactor the named_mutex in the V4L2 backend to use RAII for file descriptors and an atomic counter for lock tracking, remove legacy maps and recursive mutexes, switch to Linux OFD locks, and introduce a UVC power stress test.

  • Replaced per-device recursive mutex maps and lock counters with a single std::atomic<int> counter.
  • Simplified constructor/destructor to open/close the device file descriptor directly.
  • Refactored lock(), unlock(), and try_lock() to use fcntl-based OFD locking.
  • Added a multi-threaded UVC power stress test (test-uvc-power-stress-test.py).

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
unit-tests/live/options/test-uvc-power-stress-test.py Added a stress test to exercise concurrent UVC power-option commands across multiple threads.
src/linux/backend-v4l2.h Removed legacy recursive mutexes and maps; introduced std::atomic<int> _lock_counter.
src/linux/backend-v4l2.cpp Refactored named_mutex methods to use OFD locks via fcntl, and simplified file descriptor RAII.

Comment thread src/linux/backend-v4l2.cpp Resolved
Comment thread src/linux/backend-v4l2.cpp Resolved
Comment thread src/linux/backend-v4l2.cpp Resolved
Comment thread src/linux/backend-v4l2.cpp Resolved

@Nir-Az Nir-Az left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Nir-Az
Nir-Az merged commit 54dbe41 into realsenseai:development Jul 15, 2025
@OhadMeir
OhadMeir deleted the linux_uvc branch November 3, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants