[all-commits] [llvm/llvm-project] 3f981f: sanitizer_common: add new mutex
Dmitry Vyukov via All-commits
all-commits at lists.llvm.org
Mon Jul 19 23:20:11 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3f981fc1861a0683eb00b442d4cad7410d4a8e59
https://github.com/llvm/llvm-project/commit/3f981fc1861a0683eb00b442d4cad7410d4a8e59
Author: Dmitry Vyukov <dvyukov at google.com>
Date: 2021-07-20 (Tue, 20 Jul 2021)
Changed paths:
M compiler-rt/lib/sanitizer_common/sanitizer_mutex.h
M compiler-rt/lib/sanitizer_common/tests/sanitizer_mutex_test.cpp
Log Message:
-----------
sanitizer_common: add new mutex
We currently have 3 different mutexes:
- RWMutex
- BlockingMutex
- __tsan::Mutex
RWMutex and __tsan::Mutex are roughly the same,
except that tsan version supports deadlock detection.
BlockingMutex degrades better under heavy contention
from lots of threads (blocks in OS), but much slower
for light contention and has non-portable performance
and has larger static size and is not reader-writer.
Add a new mutex that combines all advantages of these
mutexes: it's reader-writer, has fast non-contended path,
supports blocking to gracefully degrade under higher contention,
has portable size/performance.
For now it's named Mutex2 for incremental submission. The plan is to:
- land this change
- then move deadlock detection logic from tsan
- then rename it to Mutex and remove tsan Mutex
- then typedef RWMutex/BlockingMutex to this mutex
SpinMutex stays as separate type because it has faster fast path:
1 atomic RMW per lock/unlock as compared to 2 for this mutex.
Reviewed By: vitalybuka, melver
Differential Revision: https://reviews.llvm.org/D106231
More information about the All-commits
mailing list