From: Austin Clements Date: Sun, 23 Sep 2018 23:12:15 +0000 (-0400) Subject: runtime: don't call mcache.refill on systemstack X-Git-Tag: go1.12beta1~973 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=01e6cfc2a0b2f9e363c6e305b14f3393d06b13b8;p=gostls13.git runtime: don't call mcache.refill on systemstack 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 Reviewed-by: Rick Hudson TryBot-Result: Gobot Gobot --- diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index dd88d353dd..5755c9e263 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -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]