]> Cypherpunks repositories - gostls13.git/commitdiff
sync: enable profiling of RWMutex
authorLorenz Bauer <lmb@cloudflare.com>
Wed, 10 Jan 2018 10:50:19 +0000 (10:50 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 14 Feb 2018 15:38:42 +0000 (15:38 +0000)
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>
src/sync/rwmutex.go

index 4e9e8197c145590201d0df65c304332d76011a6e..9dbebfeed77e4eed3c35420c743e73da044234cb 100644 (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()