]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: run mutexevent profiling without holding semaRoot lock
authorRuss Cox <rsc@golang.org>
Mon, 13 Feb 2017 14:24:05 +0000 (09:24 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 16 Feb 2017 17:16:41 +0000 (17:16 +0000)
Suggested by Dmitry in CL 36792 review.
Clearly safe since there are many different semaRoots
that could all have profiled sudogs calling mutexevent.

Change-Id: I45eed47a5be3e513b2dad63b60afcd94800e16d1
Reviewed-on: https://go-review.googlesource.com/37104
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
src/runtime/sema.go

index 5b9a264ebd93272ddb570dd3229d657e4f4805cd..9d4cc3c036e5f4b1f0c31218223dfca2ec6a8b61 100644 (file)
@@ -174,13 +174,14 @@ func semrelease(addr *uint32) {
        s, t0 := root.dequeue(addr)
        if s != nil {
                atomic.Xadd(&root.nwait, -1)
-               if s.acquiretime != 0 {
-                       mutexevent(t0-s.acquiretime, 3)
-               }
        }
        unlock(&root.lock)
        if s != nil { // May be slow, so unlock first
+               acquiretime := s.acquiretime
                readyWithTime(s, 5)
+               if acquiretime != 0 {
+                       mutexevent(t0-acquiretime, 3)
+               }
        }
 }