Skip to content

Change HazptrHoler try_protect memory fence from light to heavy#2522

Open
ehds wants to merge 1 commit into
facebook:mainfrom
ehds:fix_try_protect_memory_order
Open

Change HazptrHoler try_protect memory fence from light to heavy#2522
ehds wants to merge 1 commit into
facebook:mainfrom
ehds:fix_try_protect_memory_order

Conversation

@ehds

@ehds ehds commented Oct 18, 2025

Copy link
Copy Markdown
Contributor

The protected pointer placed in hprec_ (store) should not be reordered after to read hazptr_obj (load). folly::asymmetric_thread_fence_light on Linux only prevents compiler reordering, but cannot prevent CPU reordering (x86 allows store-load reorder).

Therefore the load operation may be executed first but the protected pointer has not yet placed to hprec_, if there some other threads try to retire this hazptr, it might be success.

@meta-cla meta-cla Bot added the CLA Signed label Oct 18, 2025
The protected pointer placed in hprec_ (store) should not be reordered after to read hazptr_obj (load). folly::asymmetric_thread_fence_light on Linux only prevents compiler reordering, but cannot prevent CPU reordering (x86 allows store-load reorder).

Therefore the load operation may be executed first but the protected pointer has not yet placed to hprec_, if there some other threads try to retire this hazptr, it might be success.
@ehds ehds force-pushed the fix_try_protect_memory_order branch from c5b87fb to 5079f10 Compare October 18, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant