runtime: make ncgocall a global counter

ncgocall was stored per M, runtime.NumCgoCall lost the counter when a M die.

Fixes #46789

Change-Id: I85831fbb2713f4c30d1800d07e1f47aa0031970e
GitHub-Last-Rev: cbc15fa870
GitHub-Pull-Request: golang/go#46842
Reviewed-on: https://go-review.googlesource.com/c/go/+/329729
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
This commit is contained in:
Tao Qingyun 2021-06-22 00:24:05 +00:00 committed by Alexander Rakoczy
parent 37f9a8f69d
commit d01bc571f7
3 changed files with 5 additions and 1 deletions

View file

@ -1522,6 +1522,8 @@ found:
}
unlock(&sched.lock)
atomic.Xadd64(&ncgocall, int64(m.ncgocall))
// Release the P.
handoffp(releasep())
// After this point we must not have write barriers.