From: Michael Anthony Knyszek Date: Mon, 26 Oct 2020 19:35:23 +0000 (+0000) Subject: runtime: make sysMemStats' methods nosplit X-Git-Tag: go1.16beta1~509 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=22d2b984a680900ebbec6268f93a839286b6f130;p=gostls13.git 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 Run-TryBot: Michael Knyszek Reviewed-by: Michael Pratt Reviewed-by: Cherry Zhang Reviewed-by: Austin Clements TryBot-Result: Go Bot --- 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