Skip to content

Commit 22d2b98

Browse files
committed
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 [email protected] for finding this fix! Fixes #42218. Change-Id: Ic62db76e6a4f829355d7eaabed1727c51adfbd0f Reviewed-on: https://go-review.googlesource.com/c/go/+/265157 Trust: Michael Knyszek <[email protected]> Run-TryBot: Michael Knyszek <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Cherry Zhang <[email protected]> Reviewed-by: Austin Clements <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 751c37f commit 22d2b98

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/runtime/mstats.go

+6
Original file line numberDiff line numberDiff line change
@@ -720,11 +720,17 @@ func flushallmcaches() {
720720
type sysMemStat uint64
721721

722722
// load atomically reads the value of the stat.
723+
//
724+
// Must be nosplit as it is called in runtime initialization, e.g. newosproc0.
725+
//go:nosplit
723726
func (s *sysMemStat) load() uint64 {
724727
return atomic.Load64((*uint64)(s))
725728
}
726729

727730
// add atomically adds the sysMemStat by n.
731+
//
732+
// Must be nosplit as it is called in runtime initialization, e.g. newosproc0.
733+
//go:nosplit
728734
func (s *sysMemStat) add(n int64) {
729735
if s == nil {
730736
return

0 commit comments

Comments
 (0)