From db956262ac4125693cffb517ea7aebf6ab04ec35 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Tue, 13 May 2025 13:12:47 -0400 Subject: runtime: rename ncpu to numCPUStartup ncpu is the total logical CPU count at startup. It is never updated. For #73193, we will start using updated CPU counts for updated GOMAXPROCS, making the ncpu name a bit ambiguous. Change to a less ambiguous name. While we're at it, give the OS specific lookup functions a common name, so it can be used outside of osinit later. For #73193. Change-Id: I6a6a636cf21cc60de36b211f3c374080849fc667 Reviewed-on: https://go-review.googlesource.com/c/go/+/672277 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek Auto-Submit: Michael Pratt --- src/runtime/proc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/runtime/proc.go') diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 5d3e4e4953..f48373fe7c 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -900,7 +900,7 @@ func schedinit() { lock(&sched.lock) sched.lastpoll.Store(nanotime()) - procs := ncpu + procs := numCPUStartup if n, ok := strconv.Atoi32(gogetenv("GOMAXPROCS")); ok && n > 0 { procs = n } @@ -7230,7 +7230,7 @@ func internal_sync_runtime_canSpin(i int) bool { // GOMAXPROCS>1 and there is at least one other running P and local runq is empty. // As opposed to runtime mutex we don't do passive spinning here, // because there can be work on global runq or on other Ps. - if i >= active_spin || ncpu <= 1 || gomaxprocs <= sched.npidle.Load()+sched.nmspinning.Load()+1 { + if i >= active_spin || numCPUStartup <= 1 || gomaxprocs <= sched.npidle.Load()+sched.nmspinning.Load()+1 { return false } if p := getg().m.p.ptr(); !runqempty(p) { -- cgit v1.3-6-g1900