Skip to content
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

[15766] Update shared_mutex thirdparty to don't prioritize writers #2976

Merged
merged 19 commits into from
Nov 14, 2022

Conversation

MiguelBarro
Copy link
Contributor

@MiguelBarro MiguelBarro commented Sep 24, 2022

Description

The C++ standard requirements for shared_mutex do not specify if exclusive lock operation should preempt the shared lock one. Posix allows both behaviors but defaults to not preempting shared locks. STL implementations are split on this subject:

  • Windows, boost -> preemption (PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)
  • Linux, Mac -> not preemption ( PTHREAD_RWLOCK_PREFER_READER_NP)

In order to prevent deadlock scenarios:

  • out third party implementation avoids preemption.
  • if the framework's defaults to preemption the third party is forced.
  • code checks used to avoid deadlock on the preemption scenario have been removed.

Documentation: eProsima/Fast-DDS-docs#413

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added.
  • Any new/modified methods have been properly documented using Doxygen.
  • Fast DDS test suite has been run locally.
  • Changes are ABI compatible.
  • Changes are API compatible.
  • Documentation builds and tests pass locally.
  • [] NA New feature has been added to the versions.md file (if applicable).
  • New feature has been documented/Current behavior is correctly described in the documentation.

Reviewer Checklist

  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

@MiguelBarro
Copy link
Contributor Author

@richiprosima Please test this for me 🤯

1 similar comment
@MiguelBarro
Copy link
Contributor Author

@richiprosima Please test this for me 🤯

@MiguelBarro MiguelBarro changed the title Update shared_mutex thirdparty to don't prioritize writers [15766] Update shared_mutex thirdparty to don't prioritize writers Oct 2, 2022
@MiguelBarro MiguelBarro force-pushed the feature/shared_mutex/writer_priority branch from 97e3f18 to afcb602 Compare October 2, 2022 15:39
@MiguelBarro MiguelBarro self-assigned this Oct 2, 2022
@MiguelBarro MiguelBarro marked this pull request as ready for review October 2, 2022 16:18
@jsan-rt
Copy link
Contributor

jsan-rt commented Oct 3, 2022

@richiprosima please test this

@MiguelBarro MiguelBarro force-pushed the feature/shared_mutex/writer_priority branch from afcb602 to 1c149b0 Compare October 3, 2022 06:35
@MiguelBarro
Copy link
Contributor Author

MiguelBarro commented Oct 3, 2022

@richiprosima Please I have to rebase in order to fix docs ci, test this again 😅

@MiguelBarro MiguelBarro force-pushed the feature/shared_mutex/writer_priority branch from 1c149b0 to 5af6af9 Compare October 3, 2022 09:06
@MiguelBarro
Copy link
Contributor Author

@richiprosima Please I have to rebase in order to fix docs ci, test this again 😅

@jsan-rt jsan-rt added this to the v2.9.0 milestone Oct 3, 2022
@MiguelCompany MiguelCompany mentioned this pull request Oct 4, 2022
1 task
@MiguelBarro MiguelBarro removed this from the v2.9.0 milestone Oct 6, 2022
@MiguelBarro
Copy link
Contributor Author

@richiprosima please test this

@wade30822
Copy link

Is there any progress?

@MiguelCompany
Copy link
Member

@richiprosima Please test this

@jparisu
Copy link
Contributor

jparisu commented Nov 7, 2022

Some of the checked checklist steps look incorrect:

  • The code follows the style guidelines of this project.
  • Any new/modified methods have been properly documented using Doxygen.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added.
  • New feature has been documented/Current behavior is correctly described in the documentation.

@MiguelCompany MiguelCompany added this to the v2.8.1 milestone Nov 7, 2022
MiguelCompany and others added 8 commits November 8, 2022 08:05
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
…mework prioritizes writing.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
…texes. Now they always allow them.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
…_MUTEX value is already specified.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
@MiguelBarro
Copy link
Contributor Author

@richiprosima Please test this for me

Copy link
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

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

Apart from my comment below, please investigate this failure

include/fastrtps/utils/shared_mutex.hpp Show resolved Hide resolved
@MiguelBarro MiguelBarro force-pushed the feature/shared_mutex/writer_priority branch from 0474f1a to adf2351 Compare November 11, 2022 10:22
@MiguelBarro
Copy link
Contributor Author

@richiprosima Please test this for me

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
@MiguelBarro MiguelBarro force-pushed the feature/shared_mutex/writer_priority branch from adf2351 to 50388f0 Compare November 11, 2022 10:29
@MiguelBarro
Copy link
Contributor Author

@richiprosima Please test this for me

MiguelCompany
MiguelCompany previously approved these changes Nov 11, 2022
Copy link
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

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

LGTM with green CI!

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
@MiguelBarro
Copy link
Contributor Author

@richiprosima Please test this for me

Copy link
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

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

LGTM

@MiguelCompany MiguelCompany added ready-to-merge Ready to be merged. CI and changes have been reviewed and approved. doc-pending Issue or PR which is pending to be documented and removed doc-pending Issue or PR which is pending to be documented labels Nov 14, 2022
@MiguelCompany MiguelCompany merged commit 47d85d3 into master Nov 14, 2022
@MiguelCompany MiguelCompany deleted the feature/shared_mutex/writer_priority branch November 14, 2022 13:18
@MiguelCompany
Copy link
Member

@Mergifyio backport 2.7.x 2.6.x

@mergify
Copy link
Contributor

mergify bot commented Nov 14, 2022

backport 2.7.x 2.6.x

✅ Backports have been created

MiguelBarro added a commit that referenced this pull request Nov 15, 2022
* Add test for multithreaded creation of readers on a single subscriber.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Add DataWriter.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs 15766: Refactor of shared_mutex to select writer priority

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: CMake update to force third party shared mutex if the framework prioritizes writing.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Add atomic support for some debian distros

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Allow recursiveness on participant endpoint collection mutexes. Now they always allow them.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: linter pass

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Generate the config.h file when the USE_THIRDPARTY_SHARED_MUTEX value is already specified.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Mandatory piggyback: avoid polution on free_pools_ collection

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Add some missing members to shared_lock thirdparty

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: linter

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. shared_mutex testing

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. fixing gtest backward compatibility issues

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Add a new test to check priority is right

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing gcc build warnings

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing clang build warnings

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Make thirdparty versions always available even if none is used as eprosima::shared_mutex.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Addressing reviewers comments

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing sync issue on ProxyPool.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Co-authored-by: Miguel Company <MiguelCompany@eprosima.com>
MiguelBarro added a commit that referenced this pull request Nov 15, 2022
* Add test for multithreaded creation of readers on a single subscriber.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Add DataWriter.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs 15766: Refactor of shared_mutex to select writer priority

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: CMake update to force third party shared mutex if the framework prioritizes writing.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Add atomic support for some debian distros

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Allow recursiveness on participant endpoint collection mutexes. Now they always allow them.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: linter pass

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Generate the config.h file when the USE_THIRDPARTY_SHARED_MUTEX value is already specified.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Mandatory piggyback: avoid polution on free_pools_ collection

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Add some missing members to shared_lock thirdparty

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: linter

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. shared_mutex testing

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. fixing gtest backward compatibility issues

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Add a new test to check priority is right

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing gcc build warnings

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing clang build warnings

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Make thirdparty versions always available even if none is used as eprosima::shared_mutex.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Addressing reviewers comments

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing sync issue on ProxyPool.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Co-authored-by: Miguel Company <MiguelCompany@eprosima.com>
MiguelCompany added a commit that referenced this pull request Dec 1, 2022
* Update shared_mutex thirdparty to not prioritize writers (#2976)

* Add test for multithreaded creation of readers on a single subscriber.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Add DataWriter.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs 15766: Refactor of shared_mutex to select writer priority

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: CMake update to force third party shared mutex if the framework prioritizes writing.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Add atomic support for some debian distros

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Allow recursiveness on participant endpoint collection mutexes. Now they always allow them.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: linter pass

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Generate the config.h file when the USE_THIRDPARTY_SHARED_MUTEX value is already specified.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Mandatory piggyback: avoid polution on free_pools_ collection

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Add some missing members to shared_lock thirdparty

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: linter

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. shared_mutex testing

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. fixing gtest backward compatibility issues

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Add a new test to check priority is right

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing gcc build warnings

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing clang build warnings

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Make thirdparty versions always available even if none is used as eprosima::shared_mutex.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Addressing reviewers comments

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing sync issue on ProxyPool.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Co-authored-by: Miguel Company <MiguelCompany@eprosima.com>

* Fixing gcc warnings

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* make sure config.h is always included through fastrtps_dll.h as is expected. Do we need a foreport?

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Co-authored-by: MiguelBarro <45819833+MiguelBarro@users.noreply.github.com>
Co-authored-by: Miguel Company <MiguelCompany@eprosima.com>
Co-authored-by: Miguel Barro <miguelbarro@eprosima.com>
@Mario-DL Mario-DL mentioned this pull request Dec 1, 2022
1 task
MiguelBarro added a commit that referenced this pull request Jan 31, 2023
* Add test for multithreaded creation of readers on a single subscriber.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Add DataWriter.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs 15766: Refactor of shared_mutex to select writer priority

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: CMake update to force third party shared mutex if the framework prioritizes writing.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Add atomic support for some debian distros

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Allow recursiveness on participant endpoint collection mutexes. Now they always allow them.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: linter pass

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Generate the config.h file when the USE_THIRDPARTY_SHARED_MUTEX value is already specified.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Mandatory piggyback: avoid polution on free_pools_ collection

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: Add some missing members to shared_lock thirdparty

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766: linter

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. shared_mutex testing

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. fixing gtest backward compatibility issues

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Add a new test to check priority is right

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing gcc build warnings

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing clang build warnings

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Make thirdparty versions always available even if none is used as eprosima::shared_mutex.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Addressing reviewers comments

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

* Refs 15766. Fixing sync issue on ProxyPool.

Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
Co-authored-by: Miguel Company <MiguelCompany@eprosima.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Ready to be merged. CI and changes have been reviewed and approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants