]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: delineate which memstats are system stats with a type
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 29 Jul 2020 20:25:05 +0000 (20:25 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 26 Oct 2020 18:09:41 +0000 (18:09 +0000)
commit8ebc58452af3a586a3da1f68725bc83c78d4b073
tree0f7c114afbee98ae3b4cf70559a75dc980574281
parentdc02578ac8bb27359c7d0451ca249e47bdef2a9e
runtime: delineate which memstats are system stats with a type

This change modifies the type of several mstats fields to be a new type:
sysMemStat. This type has the same structure as the fields used to have.

The purpose of this change is to make it very clear which stats may be
used in various functions for accounting (usually the platform-specific
sys* functions, but there are others). Currently there's an implicit
understanding that the *uint64 value passed to these functions is some
kind of statistic whose value is atomically managed. This understanding
isn't inherently problematic, but we're about to change how some stats
(which currently use mSysStatInc and mSysStatDec) work, so we want to
make it very clear what the various requirements are around "sysStat".

This change also removes mSysStatInc and mSysStatDec in favor of a
method on sysMemStat. Note that those two functions were originally
written the way they were because atomic 64-bit adds required a valid G
on ARM, but this hasn't been the case for a very long time (since
golang.org/cl/14204, but even before then it wasn't clear if mutexes
required a valid G anymore). Today we implement 64-bit adds on ARM with
a spinlock table.

Change-Id: I4e9b37cf14afc2ae20cf736e874eb0064af086d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/246971
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
17 files changed:
src/runtime/export_test.go
src/runtime/heapdump.go
src/runtime/malloc.go
src/runtime/mem_aix.go
src/runtime/mem_bsd.go
src/runtime/mem_darwin.go
src/runtime/mem_js.go
src/runtime/mem_linux.go
src/runtime/mem_plan9.go
src/runtime/mem_windows.go
src/runtime/mfixalloc.go
src/runtime/mgcscavenge.go
src/runtime/mheap.go
src/runtime/mpagealloc.go
src/runtime/mranges.go
src/runtime/mstats.go
src/runtime/os_darwin.go