aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2015-10-15 13:25:19 -0400
committerAustin Clements <austin@google.com>2015-10-15 19:33:11 +0000
commit71a76476627fb0752d1b816406da4e5a6511c2c9 (patch)
treeb2e4d66dad0a23a0b29f13a83ffafa071982813b
parentc257dfb178f00449dd344204219aad56e3e90de6 (diff)
downloadgo-71a76476627fb0752d1b816406da4e5a6511c2c9.tar.gz
go-71a76476627fb0752d1b816406da4e5a6511c2c9.zip
[release-branch.go1.5] runtime: fix recursive GC assist better
Commit c257dfb attempted to fix recursive allocation in gcAssistAlloc; however, it only reduced it: setting gp.gcalloc to 0 isn't sufficient to disable assists at the beginning of the GC cycle when gp.gcscanwork is also small or zero. Fix this recursion more completely by setting gcalloc to a sentinel value that directly disables assists. Fixes #12894 (again). Change-Id: I9599566222d8f540d0b39806846bfc702e6666e5 Reviewed-on: https://go-review.googlesource.com/15891 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
-rw-r--r--src/runtime/mgcmark.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go
index e5dfa72026..64cc1af64f 100644
--- a/src/runtime/mgcmark.go
+++ b/src/runtime/mgcmark.go
@@ -152,6 +152,11 @@ func gcAssistAlloc(size uintptr, allowAssist bool) {
}
// Record allocation.
+ if gp.gcalloc+size < gp.gcalloc {
+ // gcalloc would overflow, or it's set to a sentinel
+ // value to prevent recursive assist.
+ return
+ }
gp.gcalloc += size
if !allowAssist {
@@ -295,7 +300,7 @@ retry:
// timeSleep may allocate, so avoid recursive assist.
gcalloc := gp.gcalloc
- gp.gcalloc = 0
+ gp.gcalloc = ^uintptr(0)
timeSleep(100 * 1000)
gp.gcalloc = gcalloc
goto retry