]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.5] runtime: fix recursive GC assist better
authorAustin Clements <austin@google.com>
Thu, 15 Oct 2015 17:25:19 +0000 (13:25 -0400)
committerAustin Clements <austin@google.com>
Thu, 15 Oct 2015 19:33:11 +0000 (19:33 +0000)
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>
src/runtime/mgcmark.go

index e5dfa72026805006361aa2caf9f7e82be5232cdb..64cc1af64f3bfe203a91f9503b4225fa435aadce 100644 (file)
@@ -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