-
Notifications
You must be signed in to change notification settings - Fork 140
[PATCH v3] api: barrier: clarify thread barrier reuse #2262
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
Merged
MatiasElo
merged 3 commits into
OpenDataPlane:master
from
JannePeltonen:api-thread-barrier
Dec 30, 2025
Merged
[PATCH v3] api: barrier: clarify thread barrier reuse #2262
MatiasElo
merged 3 commits into
OpenDataPlane:master
from
JannePeltonen:api-thread-barrier
Dec 30, 2025
Conversation
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
MatiasElo
reviewed
Sep 22, 2025
jerinjacobk
approved these changes
Dec 15, 2025
psavol
approved these changes
Dec 19, 2025
Collaborator
psavol
left a comment
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.
Typo corrections needed, otherwise ok.
0269b47 to
fbc3164
Compare
Collaborator
Author
|
v2: fixed typos, added a test, rebased |
MatiasElo
approved these changes
Dec 30, 2025
Explicitly state that a memory barrier can be reused without initializing it again. Make it clear that no more than N threads may be inside odp_barrier_wait() for a barrier of N threads. Without this requirement, an application could e.g. wait a barrier in thread 1 and thread 2, and, when thread 2 returns from the barrier (at which point thread 1 is supposed to have been unblocked too), tell threads 3 and 4 to wait for the same barrier. If threads 3 and 4 manage to start waiting for the barrier before thread 1 has returned from odp_barrier_wait(), thread 1 may continue to be blocked in the counter based implementation used in multiple ODPs. Clarify that a barrier must be initialized before first use and can be reinitialized if not in use. Make also a remark about the thread-unsafety of the initialization function. Signed-off-by: Janne Peltonen <janne.peltonen@nokia.com> Reviewed-by: Jerin Jacob <jerinj@marvell.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com> Reviewed-by: Matias Elo <matias.elo@nokia.com>
Use atomic types for variables that may be accessed by multiple threads simulteneously. Also remove a few unused lines of code and an outdated comment. Use of relaxed memory order in the custom barrier implementation is dubious and probably wrong but not fixed by this commit. Signed-off-by: Janne Peltonen <janne.peltonen@nokia.com> Reviewed-by: Matias Elo <matias.elo@nokia.com>
Add a test that reuses a thread barrier without reinitialization. Signed-off-by: Janne Peltonen <janne.peltonen@nokia.com> Reviewed-by: Matias Elo <matias.elo@nokia.com>
fbc3164 to
5a386b1
Compare
Collaborator
Author
|
v3: added review tags, and now actually rebased |
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.
Explicitly state that a memory barrier can be reused without initializing it again.
Make it clear that no more than N threads may be inside odp_barrier_wait() for a barrier of N threads. Without this requirement, an application could e.g. wait a barrier in thread 1 and thread 2, and, when thread 2 returns from the barrier (at which point thread 1 is supposed to have been unblocked too), tell threads 3 and 4 to wait for the same barrier. If threads 3 and 4 manage to start waiting for the barrier before thread 1 has returned from odp_barrier_wait(), thread 1 may continue to be blocked in the counter based implementation used in multiple ODPs.
Clarify that a barrier must be initialized before first use and can be reinitialized if not in use. Make also a remark about the thread-unsafety of the initialization function.