diff options
| author | 2014-06-23 17:53:09 -0700 | |
|---|---|---|
| committer | 2014-06-23 17:55:22 -0700 | |
| commit | a1c1c71e24c93a720bbf13de129c75a9a0bde37a (patch) | |
| tree | 7c86b8684123587894997077680fdc7324954f9c /runtime/gc/allocator/rosalloc.cc | |
| parent | 9462a31caedefac3e04bd4aa5088e050ed188b30 (diff) | |
Use reader lock of bulk free lock when not freeing.
Should help reduce contention observed in systrace.
Change-Id: Iadb81728d4ba797c3a68acea795b15d7f212e89b
Diffstat (limited to 'runtime/gc/allocator/rosalloc.cc')
| -rw-r--r-- | runtime/gc/allocator/rosalloc.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc index 55262f2359..656c55bb19 100644 --- a/runtime/gc/allocator/rosalloc.cc +++ b/runtime/gc/allocator/rosalloc.cc @@ -529,7 +529,7 @@ size_t RosAlloc::FreeInternal(Thread* self, void* ptr) { } size_t RosAlloc::Free(Thread* self, void* ptr) { - ReaderMutexLock rmu(self, bulk_free_lock_); + WriterMutexLock rmu(self, bulk_free_lock_); return FreeInternal(self, ptr); } @@ -1642,7 +1642,7 @@ void RosAlloc::SetFootprintLimit(size_t new_capacity) { void RosAlloc::RevokeThreadLocalRuns(Thread* thread) { Thread* self = Thread::Current(); // Avoid race conditions on the bulk free bit maps with BulkFree() (GC). - WriterMutexLock wmu(self, bulk_free_lock_); + ReaderMutexLock wmu(self, bulk_free_lock_); for (size_t idx = 0; idx < kNumThreadLocalSizeBrackets; idx++) { MutexLock mu(self, *size_bracket_locks_[idx]); Run* thread_local_run = reinterpret_cast<Run*>(thread->GetRosAllocRun(idx)); @@ -1720,7 +1720,7 @@ void RosAlloc::AssertThreadLocalRunsAreRevoked(Thread* thread) { if (kIsDebugBuild) { Thread* self = Thread::Current(); // Avoid race conditions on the bulk free bit maps with BulkFree() (GC). - WriterMutexLock wmu(self, bulk_free_lock_); + ReaderMutexLock wmu(self, bulk_free_lock_); for (size_t idx = 0; idx < kNumThreadLocalSizeBrackets; idx++) { MutexLock mu(self, *size_bracket_locks_[idx]); Run* thread_local_run = reinterpret_cast<Run*>(thread->GetRosAllocRun(idx)); @@ -1867,7 +1867,7 @@ void RosAlloc::Verify() { CHECK(Locks::mutator_lock_->IsExclusiveHeld(self)) << "The mutator locks isn't exclusively locked at RosAlloc::Verify()"; MutexLock mu(self, *Locks::thread_list_lock_); - WriterMutexLock wmu(self, bulk_free_lock_); + ReaderMutexLock wmu(self, bulk_free_lock_); std::vector<Run*> runs; { MutexLock mu(self, lock_); |