aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2018-03-06 21:28:24 -0800
committerJosh Bleecher Snyder <josharian@gmail.com>2018-05-03 17:04:22 +0000
commit4d7cf3fedbc382215df5ff6167ee9782a9cc9375 (patch)
tree47fa97c217aab8e22fedeed15e43a5be61890b56 /src/runtime/proc.go
parent4704149e04b89a2c3f3d361facdab55b659fb527 (diff)
downloadgo-4d7cf3fedbc382215df5ff6167ee9782a9cc9375.tar.xz
runtime: convert g.waitreason from string to uint8
Every time I poke at #14921, the g.waitreason string pointer writes show up. They're not particularly important performance-wise, but it'd be nice to clear the noise away. And it does open up a few extra bytes in the g struct for some future use. This is a re-roll of CL 99078, which was rolled back because of failures on s390x. Those failures were apparently due to an old version of gdb. Change-Id: Icc2c12f449b2934063fd61e272e06237625ed589 Reviewed-on: https://go-review.googlesource.com/111256 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Munday <mike.munday@ibm.com>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 3f9efbdace..9b55feeff2 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -214,7 +214,7 @@ func main() {
}
}
if atomic.Load(&panicking) != 0 {
- gopark(nil, nil, "panicwait", traceEvGoStop, 1)
+ gopark(nil, nil, waitReasonPanicWait, traceEvGoStop, 1)
}
exit(0)
@@ -245,7 +245,7 @@ func forcegchelper() {
throw("forcegc: phase error")
}
atomic.Store(&forcegc.idle, 1)
- goparkunlock(&forcegc.lock, "force gc (idle)", traceEvGoBlock, 1)
+ goparkunlock(&forcegc.lock, waitReasonForceGGIdle, traceEvGoBlock, 1)
// this goroutine is explicitly resumed by sysmon
if debug.gctrace > 0 {
println("GC forced")
@@ -274,7 +274,11 @@ func goschedguarded() {
// If unlockf returns false, the goroutine is resumed.
// unlockf must not access this G's stack, as it may be moved between
// the call to gopark and the call to unlockf.
-func gopark(unlockf func(*g, unsafe.Pointer) bool, lock unsafe.Pointer, reason string, traceEv byte, traceskip int) {
+// Reason explains why the goroutine has been parked.
+// It is displayed in stack traces and heap dumps.
+// Reasons should be unique and descriptive.
+// Do not re-use reasons, add new ones.
+func gopark(unlockf func(*g, unsafe.Pointer) bool, lock unsafe.Pointer, reason waitReason, traceEv byte, traceskip int) {
mp := acquirem()
gp := mp.curg
status := readgstatus(gp)
@@ -293,7 +297,7 @@ func gopark(unlockf func(*g, unsafe.Pointer) bool, lock unsafe.Pointer, reason s
// Puts the current goroutine into a waiting state and unlocks the lock.
// The goroutine can be made runnable again by calling goready(gp).
-func goparkunlock(lock *mutex, reason string, traceEv byte, traceskip int) {
+func goparkunlock(lock *mutex, reason waitReason, traceEv byte, traceskip int) {
gopark(parkunlock_c, unsafe.Pointer(lock), reason, traceEv, traceskip)
}
@@ -2676,7 +2680,7 @@ func goexit0(gp *g) {
gp._defer = nil // should be true already but just in case.
gp._panic = nil // non-nil for Goexit during panic. points at stack-allocated data.
gp.writebuf = nil
- gp.waitreason = ""
+ gp.waitreason = 0
gp.param = nil
gp.labels = nil
gp.timer = nil
@@ -4542,7 +4546,7 @@ func schedtrace(detailed bool) {
if lockedm != nil {
id2 = lockedm.id
}
- print(" G", gp.goid, ": status=", readgstatus(gp), "(", gp.waitreason, ") m=", id1, " lockedm=", id2, "\n")
+ print(" G", gp.goid, ": status=", readgstatus(gp), "(", gp.waitreason.String(), ") m=", id1, " lockedm=", id2, "\n")
}
unlock(&allglock)
unlock(&sched.lock)