From: Leonard Wang Date: Sat, 11 Sep 2021 12:53:24 +0000 (+0800) Subject: runtime: add mp parameter for getMCache X-Git-Tag: go1.18beta1~1142 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=84ba117fd7446030f93ab679d5c819dc028ad881;p=gostls13.git runtime: add mp parameter for getMCache Since all callers of getMCache appear to have mp available, we pass the mp to getMCache, and reduce one call to getg. And after modification, getMCache is also inlined. Change-Id: Ib7880c118336acc026ecd7c60c5a88722c3ddfc7 Reviewed-on: https://go-review.googlesource.com/c/go/+/349329 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Michael Knyszek Trust: Michael Knyszek Trust: Carlos Amedee --- diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index f8d5d48a28..7affe244a2 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -972,7 +972,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { shouldhelpgc := false dataSize := size - c := getMCache() + c := getMCache(mp) if c == nil { throw("mallocgc called without a P or outside bootstrapping") } @@ -1247,7 +1247,7 @@ func reflect_unsafe_NewArray(typ *_type, n int) unsafe.Pointer { } func profilealloc(mp *m, x unsafe.Pointer, size uintptr) { - c := getMCache() + c := getMCache(mp) if c == nil { throw("profilealloc called without a P or outside bootstrapping") } diff --git a/src/runtime/mcache.go b/src/runtime/mcache.go index a9e959109a..21c36ca750 100644 --- a/src/runtime/mcache.go +++ b/src/runtime/mcache.go @@ -122,9 +122,9 @@ func freemcache(c *mcache) { // // Returns nil if we're not bootstrapping or we don't have a P. The caller's // P must not change, so we must be in a non-preemptible state. -func getMCache() *mcache { +func getMCache(mp *m) *mcache { // Grab the mcache, since that's where stats live. - pp := getg().m.p.ptr() + pp := mp.p.ptr() var c *mcache if pp == nil { // We will be called without a P while bootstrapping,