aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2021-12-07 15:59:14 -0500
committerMichael Pratt <mpratt@google.com>2022-01-19 16:33:05 +0000
commit3e45eb3ce1f28ccb6e4150b6c2c09ca8568874e6 (patch)
treef56b3a51594247c84f6c2dbcb0958c381bd9ae19 /src/runtime/proc.go
parentbec2cc370871b998a131f5f363dab4a14b5f2eb2 (diff)
downloadgo-3e45eb3ce1f28ccb6e4150b6c2c09ca8568874e6.tar.gz
go-3e45eb3ce1f28ccb6e4150b6c2c09ca8568874e6.zip
runtime: do not inherit labels on system goroutines
GC background mark worker goroutines are created when the first GC is triggered (or next GC after GOMAXPROCS increases). Since the GC can be triggered from a user goroutine, those workers will inherit any pprof labels from the user goroutine. That isn't meaningful, so avoid it by excluding system goroutines from inheriting labels. Fixes #50032 Change-Id: Ib425ae561a3466007ff5deec86b9c51829ab5507 Reviewed-on: https://go-review.googlesource.com/c/go/+/369983 Reviewed-by: Austin Clements <austin@google.com> Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 7509f7632f..eee0a25fee 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -4300,11 +4300,13 @@ func newproc1(fn *funcval, callergp *g, callerpc uintptr) *g {
newg.gopc = callerpc
newg.ancestors = saveAncestors(callergp)
newg.startpc = fn.fn
- if _g_.m.curg != nil {
- newg.labels = _g_.m.curg.labels
- }
if isSystemGoroutine(newg, false) {
atomic.Xadd(&sched.ngsys, +1)
+ } else {
+ // Only user goroutines inherit pprof labels.
+ if _g_.m.curg != nil {
+ newg.labels = _g_.m.curg.labels
+ }
}
// Track initial transition?
newg.trackingSeq = uint8(fastrand())