aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mcache.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2018-09-22 15:59:01 -0400
committerAustin Clements <austin@google.com>2018-09-28 18:39:43 +0000
commit2d23ece135076698ea4724b02f07d71d1f2145fb (patch)
treea6e97815d7844e2f2da3c3735f0524fc44d768e5 /src/runtime/mcache.go
parenteac99c44667a748f8b00f38c5f44beb41e1b4503 (diff)
downloadgo-2d23ece135076698ea4724b02f07d71d1f2145fb.tar.gz
go-2d23ece135076698ea4724b02f07d71d1f2145fb.zip
runtime: remove redundant locking in mcache.refill
mcache.refill acquires g.m.locks, which is pointless because the caller itself absolutely must have done so already to prevent ownership of mcache from shifting. Also, mcache.refill's documentation is generally a bit out-of-date, so this cleans this up. Change-Id: Idc8de666fcaf3c3d96006bd23a8f307539587d6c Reviewed-on: https://go-review.googlesource.com/138195 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/mcache.go')
-rw-r--r--src/runtime/mcache.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/runtime/mcache.go b/src/runtime/mcache.go
index d0b007f915..8486f69569 100644
--- a/src/runtime/mcache.go
+++ b/src/runtime/mcache.go
@@ -101,12 +101,12 @@ func freemcache(c *mcache) {
})
}
-// Gets a span that has a free object in it and assigns it
-// to be the cached span for the given sizeclass. Returns this span.
+// refill acquires a new span of span class spc for c. This span will
+// have at least one free object. The current span in c must be full.
+//
+// Must run in a non-preemptible context since otherwise the owner of
+// c could change.
func (c *mcache) refill(spc spanClass) {
- _g_ := getg()
-
- _g_.m.locks++
// Return the current cached span to the central lists.
s := c.alloc[spc]
@@ -129,7 +129,6 @@ func (c *mcache) refill(spc spanClass) {
}
c.alloc[spc] = s
- _g_.m.locks--
}
func (c *mcache) releaseAll() {