[PATCH] D58184: [scudo][standalone] Introduce platform specific code & mutexes
Kostya Serebryany via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 25 18:23:31 PST 2019
kcc added inline comments.
================
Comment at: lib/scudo/standalone/mutex.h:45
+ if (atomic_load_relaxed(&State) == 0 &&
+ atomic_exchange(&State, 1, memory_order_acquire) == 0)
+ return;
----------------
vitalybuka wrote:
> cryptoad wrote:
> > vitalybuka wrote:
> > > this if does not look atomic
> > > atomic_compare_exchange?
> > Good point. So this is current how it's done in sanitizer_common and I didn't put additional thought into it.
> > Maybe the atomicity was too costly given that the state would eventually settle to something consistent?
> > cc: @kcc @dvyukov
> If you are going to submit as-is maybe some TODO or other comment here?
This is dvyukov's original code, but it looks just fine as is.
First load is a quick check: is the lock most likely unlocked now?
The second exchange is the actual atomic part.
Repository:
rCRT Compiler Runtime
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58184/new/
https://reviews.llvm.org/D58184
More information about the llvm-commits
mailing list