mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: make the wait reason for a g blocked on a mutex more specific
This change adds 3 new waitReasons that correspond to sync.Mutex.Lock, sync.RWMutex.RLock, and sync.RWMutex.Lock that are plumbed down into semacquire1 by exporting new functions to the sync package from the runtime. Currently these three functions show up as "semacquire" in backtraces which isn't very clear, though the stack trace itself should reveal what's really going on. This represents a minor improvement to backtrace readability, though blocking on an RWMutex.w.Lock will still show up as blocking on a regular mutex (I suppose technically it is). This is a step toward helping the runtime identify when a goroutine is blocked on a mutex of some kind. For #49881. Change-Id: Ia409b4d27e117fe4bfdc25fa541e9c58d6d587b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/427616 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
b7c28f484d
commit
a2c396ce00
6 changed files with 33 additions and 13 deletions
|
|
@ -40,7 +40,7 @@ func metricsLock() {
|
|||
// Acquire the metricsSema but with handoff. Operations are typically
|
||||
// expensive enough that queueing up goroutines and handing off between
|
||||
// them will be noticeably better-behaved.
|
||||
semacquire1(&metricsSema, true, 0, 0)
|
||||
semacquire1(&metricsSema, true, 0, 0, waitReasonSemacquire)
|
||||
if raceenabled {
|
||||
raceacquire(unsafe.Pointer(&metricsSema))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue