aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/runtime/mstats.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/runtime/mstats.go b/src/runtime/mstats.go
index f40bccad17..ba508729c5 100644
--- a/src/runtime/mstats.go
+++ b/src/runtime/mstats.go
@@ -513,6 +513,12 @@ func readGCStats_m(pauses *[]uint64) {
//go:nowritebarrier
func updatememstats() {
+ // Flush mcaches to mcentral before doing anything else.
+ //
+ // Flushing to the mcentral may in general cause stats to
+ // change as mcentral data structures are manipulated.
+ systemstack(flushallmcaches)
+
memstats.mcache_inuse = uint64(mheap_.cachealloc.inuse)
memstats.mspan_inuse = uint64(mheap_.spanalloc.inuse)
memstats.sys = memstats.heap_sys + memstats.stacks_sys + memstats.mspan_sys +
@@ -537,9 +543,6 @@ func updatememstats() {
memstats.by_size[i].nfree = 0
}
- // Flush mcache's to mcentral.
- systemstack(flushallmcaches)
-
// Aggregate local stats.
cachestats()