Permalink
Browse files

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>
  • Loading branch information...
lmb authored and bradfitz committed Jan 10, 2018
1 parent 8cb4327 commit 88ba64582703cea0d66a098730215554537572de
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/sync/rwmutex.go
@@ -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()

0 comments on commit 88ba645

Please sign in to comment.