1
0
mirror of https://github.com/golang/go synced 2024-11-19 16:54:44 -07:00

sync: enable profiling of RWMutex

Include reader / writer interactions of RWMutex in the mutex profile.
Writer contention is already included in the profile, since a plain Mutex
is used to control exclusion.

Fixes #18496

Change-Id: Ib0dc1ffa0fd5e6d964a6f7764d7f09556eb63f00
Reviewed-on: https://go-review.googlesource.com/87095
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
This commit is contained in:
Lorenz Bauer 2018-01-10 10:50:19 +00:00 committed by Brad Fitzpatrick
parent 8cb4327ea3
commit 88ba645827

View File

@ -47,7 +47,7 @@ func (rw *RWMutex) RLock() {
}
if atomic.AddInt32(&rw.readerCount, 1) < 0 {
// A writer is pending, wait for it.
runtime_Semacquire(&rw.readerSem)
runtime_SemacquireMutex(&rw.readerSem, false)
}
if race.Enabled {
race.Enable()
@ -95,7 +95,7 @@ func (rw *RWMutex) Lock() {
r := atomic.AddInt32(&rw.readerCount, -rwmutexMaxReaders) + rwmutexMaxReaders
// Wait for active readers.
if r != 0 && atomic.AddInt32(&rw.readerWait, r) != 0 {
runtime_Semacquire(&rw.writerSem)
runtime_SemacquireMutex(&rw.writerSem, false)
}
if race.Enabled {
race.Enable()