Skip to content

Conversation

@alekswn
Copy link
Contributor

@alekswn alekswn commented Jan 5, 2026

  • Converted ibv_mr_reg_ct and ibv_mr_reg_sz to ofi_atomic64
  • Updated MR registration/deregistration code to use atomic operations
  • Maintained existing logging functionality with thread-safe counter reads

} \
static inline \
size_t ofi_atomic_inc_counter(ofi_atomic_counter *atomic) \
{ \
Copy link
Contributor

Choose a reason for hiding this comment

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

Can it be merged with ofi_atomic_inc/add/set/dec functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that can be done, but not so trivial. The way OFI_ATOMIC_DEFINE macro is implemented it does not have options for unsigned integer and memory model (following Windows model I guess). Therefore the macro definition is going to become extremely complex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm excluding the new define from this PR. Going to cut a new PR with better macros.
For the time being we can use signed integer ofi_atomic64_t.

@alekswn alekswn marked this pull request as draft January 5, 2026 20:45
@alekswn alekswn force-pushed the fix-efa_mr_reg_impl-race branch 4 times, most recently from a775e45 to 1643733 Compare January 7, 2026 15:56
Convert ibv_mr_reg_ct and ibv_mr_reg_sz from plain size_t to
ofi_atomic64_t to ensure thread-safe access in multi-threaded
environments. This prevents race conditions when multiple threads
register/deregister memory regions concurrently.

Changes:
- Use ofi_atomic_add64()/ofi_atomic_inc64() for MR registration
- Use ofi_atomic_sub64()/ofi_atomic_dec64() for deregistration
- Maintain existing logging functionality with atomic-safe reads

Signed-off-by: Alexey Novikov <[email protected]>
@alekswn alekswn force-pushed the fix-efa_mr_reg_impl-race branch from 1643733 to 5e9ab42 Compare January 7, 2026 18:30
@alekswn
Copy link
Contributor Author

alekswn commented Jan 7, 2026

bot:aws:retest

@alekswn alekswn marked this pull request as ready for review January 7, 2026 21:30
@alekswn
Copy link
Contributor Author

alekswn commented Jan 7, 2026

bot:aws:retest

1 similar comment
@alekswn
Copy link
Contributor Author

alekswn commented Jan 8, 2026

bot:aws:retest

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.

2 participants