]> Cypherpunks repositories - gostls13.git/commit
runtime: fix stack use accounting
authorAustin Clements <austin@google.com>
Mon, 27 Apr 2015 18:50:42 +0000 (14:50 -0400)
committerAustin Clements <austin@google.com>
Mon, 27 Apr 2015 23:09:39 +0000 (23:09 +0000)
commit7c7cd69591440b565bde2bfb2c804a99a17999ad
tree32ffb916b36638ddbe1ded319ac32de6975d2bc3
parentd707a6e0e2fe68c7cdcb552e920e8c286286fb56
runtime: fix stack use accounting

ReadMemStats accounts for stacks slightly differently than the runtime
does internally. Internally, only stacks allocated by newosproc0 are
accounted in memstats.stacks_sys and other stacks are accounted in
heap_sys. readmemstats_m shuffles the statistics so all stacks are
accounted in StackSys rather than HeapSys.

However, currently, readmemstats_m assumes StackSys will be zero when
it does this shuffle. This was true until commit 6ad33be. If it isn't
(e.g., if something called newosproc0), StackSys+HeapSys will be
different before and after this shuffle, and the Sys sum that was
computed earlier will no longer agree with the sum of its components.

Fix this by making the shuffle in readmemstats_m not assume that
StackSys is zero.

Fixes #10585.

Change-Id: If13991c8de68bd7b85e1b613d3f12b4fd6fd5813
Reviewed-on: https://go-review.googlesource.com/9366
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/mstats.go