diff options
| author | Michael Pratt <mpratt@google.com> | 2025-05-28 14:10:38 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-05-28 15:02:02 -0700 |
| commit | 6160fa59b6523e781db47eb1ee8f929398f2bb78 (patch) | |
| tree | 8af0c81321032e2938f71b05788aa85b14636221 /src/runtime/proc.go | |
| parent | ae6c098f482f74a077ee690082e4b785d4689999 (diff) | |
| download | go-6160fa59b6523e781db47eb1ee8f929398f2bb78.tar.xz | |
runtime: rename updateGOMAXPROCS to updateMaxProcsG
There are other parts to updating GOMAXPROCS than just the helper
goroutine, so make the naming more specific.
For #73193.
Change-Id: I6a6a636c31ac80c8d76afe90c0bfc29d3086af4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/677035
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/proc.go')
| -rw-r--r-- | src/runtime/proc.go | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 4925528783..fe9f07723c 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -6546,7 +6546,7 @@ func schedtrace(detailed bool) { unlock(&sched.lock) } -type updateGOMAXPROCSState struct { +type updateMaxProcsGState struct { lock mutex g *g idle atomic.Bool @@ -6556,28 +6556,30 @@ type updateGOMAXPROCSState struct { } var ( - updateGOMAXPROCS updateGOMAXPROCSState - + // GOMAXPROCS update godebug metric. Incremented if automatic + // GOMAXPROCS updates actually change the value of GOMAXPROCS. updatemaxprocs = &godebugInc{name: "updatemaxprocs"} + + updateMaxProcsG updateMaxProcsGState ) // Start GOMAXPROCS update helper goroutine. // // This is based on forcegchelper. func defaultGOMAXPROCSUpdateEnable() { - go updateGOMAXPROCSHelper() + go updateMaxProcsGoroutine() } -func updateGOMAXPROCSHelper() { - updateGOMAXPROCS.g = getg() - lockInit(&updateGOMAXPROCS.lock, lockRankUpdateGOMAXPROCS) +func updateMaxProcsGoroutine() { + updateMaxProcsG.g = getg() + lockInit(&updateMaxProcsG.lock, lockRankUpdateMaxProcsG) for { - lock(&updateGOMAXPROCS.lock) - if updateGOMAXPROCS.idle.Load() { - throw("updateGOMAXPROCS: phase error") + lock(&updateMaxProcsG.lock) + if updateMaxProcsG.idle.Load() { + throw("updateMaxProcsGoroutine: phase error") } - updateGOMAXPROCS.idle.Store(true) - goparkunlock(&updateGOMAXPROCS.lock, waitReasonUpdateGOMAXPROCSIdle, traceBlockSystemGoroutine, 1) + updateMaxProcsG.idle.Store(true) + goparkunlock(&updateMaxProcsG.lock, waitReasonUpdateGOMAXPROCSIdle, traceBlockSystemGoroutine, 1) // This goroutine is explicitly resumed by sysmon. stw := stopTheWorldGC(stwGOMAXPROCS) @@ -6595,7 +6597,7 @@ func updateGOMAXPROCSHelper() { // // TODO(prattmic): this could use a nicer API. Perhaps add it to the // stw parameter? - newprocs = updateGOMAXPROCS.procs + newprocs = updateMaxProcsG.procs newprocsCustom = false startTheWorldGC(stw) @@ -6626,14 +6628,14 @@ func sysmonUpdateGOMAXPROCS() { // Sysmon can't directly stop the world. Run the helper to do so on our // behalf. If updateGOMAXPROCS.idle is false, then a previous update is // still pending. - if updateGOMAXPROCS.idle.Load() { - lock(&updateGOMAXPROCS.lock) - updateGOMAXPROCS.procs = procs - updateGOMAXPROCS.idle.Store(false) + if updateMaxProcsG.idle.Load() { + lock(&updateMaxProcsG.lock) + updateMaxProcsG.procs = procs + updateMaxProcsG.idle.Store(false) var list gList - list.push(updateGOMAXPROCS.g) + list.push(updateMaxProcsG.g) injectglist(&list) - unlock(&updateGOMAXPROCS.lock) + unlock(&updateMaxProcsG.lock) } } |
