aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2020-10-26 19:35:23 +0000
committerMichael Knyszek <mknyszek@google.com>2020-10-26 20:10:27 +0000
commit22d2b984a680900ebbec6268f93a839286b6f130 (patch)
treeadce0c47a73c491f412e00fbb7c636f8ac7b3024
parent751c37fd629e0ebb18c39a219fab2b224d016b70 (diff)
downloadgo-22d2b984a680900ebbec6268f93a839286b6f130.tar.gz
go-22d2b984a680900ebbec6268f93a839286b6f130.zip
runtime: make sysMemStats' methods nosplit
sysMemStats are updated early on in runtime initialization, so triggering a stack growth would be bad. Mark them nosplit. Thank you so much to cherryyz@google.com for finding this fix! Fixes #42218. Change-Id: Ic62db76e6a4f829355d7eaabed1727c51adfbd0f Reviewed-on: https://go-review.googlesource.com/c/go/+/265157 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org>
-rw-r--r--src/runtime/mstats.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/runtime/mstats.go b/src/runtime/mstats.go
index 512a06cffa..07f466ec49 100644
--- a/src/runtime/mstats.go
+++ b/src/runtime/mstats.go
@@ -720,11 +720,17 @@ func flushallmcaches() {
type sysMemStat uint64
// load atomically reads the value of the stat.
+//
+// Must be nosplit as it is called in runtime initialization, e.g. newosproc0.
+//go:nosplit
func (s *sysMemStat) load() uint64 {
return atomic.Load64((*uint64)(s))
}
// add atomically adds the sysMemStat by n.
+//
+// Must be nosplit as it is called in runtime initialization, e.g. newosproc0.
+//go:nosplit
func (s *sysMemStat) add(n int64) {
if s == nil {
return