diff options
author | Austin Clements <austin@google.com> | 2017-04-21 11:45:44 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2017-04-21 17:41:51 +0000 |
commit | 9d36163c0b35ddd384534f850fb04170e0d0c7c4 (patch) | |
tree | 4ad8eb06f8993b0ac6a444f1ca45bcc2fb231380 /src/runtime/mstats.go | |
parent | 44fe0820c6c304cb56592b07c0d9b2f90c3a20ce (diff) | |
download | go-9d36163c0b35ddd384534f850fb04170e0d0c7c4.tar.gz go-9d36163c0b35ddd384534f850fb04170e0d0c7c4.zip |
runtime: consistently use atomic loads for heap_live
heap_live is updated atomically without locking, so we should also use
atomic loads to read it. Fix the reads of heap_live that happen
outside of STW to be atomic.
Change-Id: Idca9451c348168c2a792a9499af349833a3c333f
Reviewed-on: https://go-review.googlesource.com/41371
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/mstats.go')
-rw-r--r-- | src/runtime/mstats.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/mstats.go b/src/runtime/mstats.go index c2fa6ad9a9..ae8c1e39c1 100644 --- a/src/runtime/mstats.go +++ b/src/runtime/mstats.go @@ -121,6 +121,8 @@ type mstats struct { // leads to a conservative GC rate rather than a GC rate that // is potentially too low. // + // Reads should likewise be atomic (or during STW). + // // Whenever this is updated, call traceHeapAlloc() and // gcController.revise(). heap_live uint64 |