aboutsummaryrefslogtreecommitdiff
path: root/test/codegen/arithmetic.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2025-12-04 23:27:03 +0000
committerMichael Knyszek <mknyszek@google.com>2025-12-05 13:48:24 -0800
commit745349712e837ef77eb7b5a21c4d4e5c7ca0371a (patch)
treeeaa0623b145ef591251f6a174b2140ef5cfbe170 /test/codegen/arithmetic.go
parentf3d572d96a25d1a0956ef828c0ff510ebf214d22 (diff)
downloadgo-745349712e837ef77eb7b5a21c4d4e5c7ca0371a.tar.xz
runtime: don't count nGsyscallNoP for extra Ms in C
In #76435, it turns out that the new metric /sched/goroutines/not-in-go:goroutines counts C threads that have called into Go before (on Linux) as not-in-go goroutines. The reason for this is that the M is still attached to the C thread on Linux as an optimization, so we don't go through all the trouble of detaching the M and, of course, decrementing nGsyscallNoP. There's an easy fix to this accounting issue. The flag on the M, isExtraInC, says whether a thread with an extra M attached no longer has any Go on its (logical) stack. When we take the P from an M in this state, we simply just don't increment nGsyscallNoP. When it calls back into Go, we similarly skip the decrement to nGsyscallNoP. This is more efficient than alternatives, like always updating nGsyscallNoP in cgocallbackg, since that would add a new read-modify-write atomic onto that fast path. It does mean we count threads in C with a P still attached as not-in-go, but this transient in most real programs, assuming the thread indeed does not call back into Go any time soon. Fixes #76435. Change-Id: Id05563bacbe35d3fae17d67fb5ed45fa43fa0548 Reviewed-on: https://go-review.googlesource.com/c/go/+/726964 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'test/codegen/arithmetic.go')
0 files changed, 0 insertions, 0 deletions