]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make sysMemStats' methods nosplit
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 26 Oct 2020 19:35:23 +0000 (19:35 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 26 Oct 2020 20:10:27 +0000 (20:10 +0000)
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>

src/runtime/mstats.go

index 512a06cffacc879bf69f5267eb70f39f3f55bb8b..07f466ec495d57d6d7156052827a843eb935949e 100644 (file)
@@ -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