runtime: fix should not compare uint64 with zero

Change-Id: I5df140cf013d5836cb401c8a37cf5c367a7f31a0
GitHub-Last-Rev: 3d7cb7abb4
GitHub-Pull-Request: golang/go#78631
Reviewed-on: https://go-review.googlesource.com/c/go/+/765181
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
Weixie Cui 2026-04-24 15:52:37 +00:00 committed by Keith Randall
parent 02d136966c
commit 9c0cb3c3a9

View file

@ -862,9 +862,10 @@ func (a *schedStatsAggregate) compute() {
// include system goroutines in this count because we included
// them above.
a.gTotal = uint64(gcount(true))
a.gWaiting = a.gTotal - (a.gRunning + a.gRunnable + a.gNonGo)
if a.gWaiting < 0 {
if a.gTotal < a.gRunning+a.gRunnable+a.gNonGo {
a.gWaiting = 0
} else {
a.gWaiting = a.gTotal - (a.gRunning + a.gRunnable + a.gNonGo)
}
unlock(&sched.lock)