]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: don't call mcache.refill on systemstack
authorAustin Clements <austin@google.com>
Sun, 23 Sep 2018 23:12:15 +0000 (19:12 -0400)
committerAustin Clements <austin@google.com>
Fri, 28 Sep 2018 18:39:49 +0000 (18:39 +0000)
mcache.refill doesn't need to run on the system stack; it just needs
to be non-preemptible. Its only caller, mcache.nextFree, also needs to
be non-preemptible, so we can remove the unnecessary systemstack
switch.

Change-Id: Iba5b3f4444855f1dc134485ba588efff3b54c426
Reviewed-on: https://go-review.googlesource.com/138196
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/malloc.go

index dd88d353ddc7b1e9ccff81bdad1656f9101f32c1..5755c9e263585b03934da3ca6877a987af25e78a 100644 (file)
@@ -733,6 +733,9 @@ func nextFreeFast(s *mspan) gclinkptr {
 // weight allocation. If it is a heavy weight allocation the caller must
 // determine whether a new GC cycle needs to be started or if the GC is active
 // whether this goroutine needs to assist the GC.
+//
+// Must run in a non-preemptible context since otherwise the owner of
+// c could change.
 func (c *mcache) nextFree(spc spanClass) (v gclinkptr, s *mspan, shouldhelpgc bool) {
        s = c.alloc[spc]
        shouldhelpgc = false
@@ -743,9 +746,7 @@ func (c *mcache) nextFree(spc spanClass) (v gclinkptr, s *mspan, shouldhelpgc bo
                        println("runtime: s.allocCount=", s.allocCount, "s.nelems=", s.nelems)
                        throw("s.allocCount != s.nelems && freeIndex == s.nelems")
                }
-               systemstack(func() {
-                       c.refill(spc)
-               })
+               c.refill(spc)
                shouldhelpgc = true
                s = c.alloc[spc]