Skip to content

Commit

Permalink
runtime: do not inherit labels on system goroutines
Browse files Browse the repository at this point in the history
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 golang#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>
  • Loading branch information
prattmic authored and jproberts committed Jun 21, 2022
1 parent 67f262f commit 9a3be38
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/runtime/proc.go
Expand Up @@ -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())
Expand Down

0 comments on commit 9a3be38

Please sign in to comment.