aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sema.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2017-06-14 11:07:24 -0400
committerAustin Clements <austin@google.com>2017-06-14 16:07:58 +0000
commitb067ad939d9ba242c5c3bdd8a24220632311c6be (patch)
tree55d3e8bd2f2c8f2e40709170b40b5d0e5722fcbb /src/runtime/sema.go
parent738739f56543a768be1eeb9a9e33f3252f4c6da1 (diff)
downloadgo-b067ad939d9ba242c5c3bdd8a24220632311c6be.tar.gz
go-b067ad939d9ba242c5c3bdd8a24220632311c6be.zip
runtime: record mutex event before readying
Currently, semrelease1 readies the next waiter before recording a mutex event. However, if the next waiter is expecting to look at the mutex profile, as is the case in TestMutexProfile, this may delay recording the event too much. Swap the order of these operations so semrelease1 records the mutex event before readying the next waiter. This also means readying the next waiter is the very last thing semrelease1 does, which seems appropriate. Fixes #19139. Change-Id: I1a62063599fdb5d49bd86061a180c0a2d659474b Reviewed-on: https://go-review.googlesource.com/45751 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Peter Weinberger <pjw@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/sema.go')
-rw-r--r--src/runtime/sema.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/runtime/sema.go b/src/runtime/sema.go
index 860765cd91..8715e07d7a 100644
--- a/src/runtime/sema.go
+++ b/src/runtime/sema.go
@@ -182,6 +182,9 @@ func semrelease1(addr *uint32, handoff bool) {
unlock(&root.lock)
if s != nil { // May be slow, so unlock first
acquiretime := s.acquiretime
+ if acquiretime != 0 {
+ mutexevent(t0-acquiretime, 3)
+ }
if s.ticket != 0 {
throw("corrupted semaphore ticket")
}
@@ -189,9 +192,6 @@ func semrelease1(addr *uint32, handoff bool) {
s.ticket = 1
}
readyWithTime(s, 5)
- if acquiretime != 0 {
- mutexevent(t0-acquiretime, 3)
- }
}
}