mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: actually fix locking in BenchmarkMSpanCountAlloc
I just submitted CL 255297 which mostly fixed this problem, but totally forgot to actually acquire/release the heap lock. Oops. Updates #41391. Change-Id: I45b42f20a9fc765c4de52476db3654d4bfe9feb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/255298 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
37f261010f
commit
10dfb1dd3d
1 changed files with 4 additions and 0 deletions
|
|
@ -991,7 +991,9 @@ type MSpan mspan
|
||||||
func AllocMSpan() *MSpan {
|
func AllocMSpan() *MSpan {
|
||||||
var s *mspan
|
var s *mspan
|
||||||
systemstack(func() {
|
systemstack(func() {
|
||||||
|
lock(&mheap_.lock)
|
||||||
s = (*mspan)(mheap_.spanalloc.alloc())
|
s = (*mspan)(mheap_.spanalloc.alloc())
|
||||||
|
unlock(&mheap_.lock)
|
||||||
})
|
})
|
||||||
return (*MSpan)(s)
|
return (*MSpan)(s)
|
||||||
}
|
}
|
||||||
|
|
@ -999,7 +1001,9 @@ func AllocMSpan() *MSpan {
|
||||||
// Free an allocated mspan.
|
// Free an allocated mspan.
|
||||||
func FreeMSpan(s *MSpan) {
|
func FreeMSpan(s *MSpan) {
|
||||||
systemstack(func() {
|
systemstack(func() {
|
||||||
|
lock(&mheap_.lock)
|
||||||
mheap_.spanalloc.free(unsafe.Pointer(s))
|
mheap_.spanalloc.free(unsafe.Pointer(s))
|
||||||
|
unlock(&mheap_.lock)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue