components/golang/patches/0027-release-branch.go1.5-runtime-fix-recursive-GC-assist.patch
author Shawn Walker-Salas <shawn.walker@oracle.com>
Thu, 21 Jan 2016 09:20:59 -0800
changeset 5331 9c955076ffe3
permissions -rw-r--r--
PSARC/2015/203 Google Go version 1.5 21480408 sample-manifest COMPONENT_VERSION transforms cause erroneous results 22297561 we should add Go to userland
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5331
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     1
From 71a76476627fb0752d1b816406da4e5a6511c2c9 Mon Sep 17 00:00:00 2001
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     2
From: Austin Clements <[email protected]>
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     3
Date: Thu, 15 Oct 2015 13:25:19 -0400
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     4
Subject: [PATCH 27/63] [release-branch.go1.5] runtime: fix recursive GC assist
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     5
 better
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     6
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     7
Commit c257dfb attempted to fix recursive allocation in gcAssistAlloc;
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     8
however, it only reduced it: setting gp.gcalloc to 0 isn't sufficient
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     9
to disable assists at the beginning of the GC cycle when gp.gcscanwork
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    10
is also small or zero.
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    11
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    12
Fix this recursion more completely by setting gcalloc to a sentinel
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    13
value that directly disables assists.
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    14
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    15
Fixes #12894 (again).
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    16
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    17
Change-Id: I9599566222d8f540d0b39806846bfc702e6666e5
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    18
Reviewed-on: https://go-review.googlesource.com/15891
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    19
Run-TryBot: Austin Clements <[email protected]>
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    20
TryBot-Result: Gobot Gobot <[email protected]>
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    21
Reviewed-by: Russ Cox <[email protected]>
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    22
---
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    23
 src/runtime/mgcmark.go | 7 ++++++-
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    24
 1 file changed, 6 insertions(+), 1 deletion(-)
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    25
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    26
diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    27
index e5dfa72..64cc1af 100644
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    28
--- a/src/runtime/mgcmark.go
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    29
+++ b/src/runtime/mgcmark.go
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    30
@@ -152,6 +152,11 @@ func gcAssistAlloc(size uintptr, allowAssist bool) {
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    31
 	}
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    32
 
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    33
 	// Record allocation.
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    34
+	if gp.gcalloc+size < gp.gcalloc {
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    35
+		// gcalloc would overflow, or it's set to a sentinel
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    36
+		// value to prevent recursive assist.
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    37
+		return
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    38
+	}
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    39
 	gp.gcalloc += size
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    40
 
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    41
 	if !allowAssist {
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    42
@@ -295,7 +300,7 @@ retry:
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    43
 
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    44
 		// timeSleep may allocate, so avoid recursive assist.
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    45
 		gcalloc := gp.gcalloc
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    46
-		gp.gcalloc = 0
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    47
+		gp.gcalloc = ^uintptr(0)
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    48
 		timeSleep(100 * 1000)
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    49
 		gp.gcalloc = gcalloc
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    50
 		goto retry
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    51
-- 
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    52
2.6.1
9c955076ffe3 PSARC/2015/203 Google Go version 1.5
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    53