mirror of
https://github.com/golang/go.git
synced 2026-04-02 17:30:01 +09:00
runtime: remove write barriers from traceRegionAlloc
The memory managed by traceRegionAlloc is off-heap by design. However, stores to the "current" pointer currently have a write barrier. This CL switches the stores to their write barrier-free equivalents. If the traceMap data structure gets extended and used elsewhere in the future, such as for runtime lock contention profiling, we might not have a P and thus won't be able to use a write barrier in this code. But for now this is just a cleanup and minor efficiency improvment. Change-Id: I3081c9d48a8471fd87534e5c4951823d6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/748120 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
@@ -92,8 +92,8 @@ func (a *traceRegionAlloc) alloc(n uintptr) *notInHeap {
|
||||
block.off.Store(n)
|
||||
x = (*notInHeap)(unsafe.Pointer(&block.data[0]))
|
||||
|
||||
// Publish the new block.
|
||||
a.current.Store(unsafe.Pointer(block))
|
||||
// Publish the new block. No write barrier as the memory is off heap.
|
||||
a.current.StoreNoWB(unsafe.Pointer(block))
|
||||
unlock(&a.lock)
|
||||
})
|
||||
return x
|
||||
@@ -112,7 +112,7 @@ func (a *traceRegionAlloc) drop() {
|
||||
}
|
||||
if current := a.current.Load(); current != nil {
|
||||
sysFree(current, unsafe.Sizeof(traceRegionAllocBlock{}), &memstats.other_sys)
|
||||
a.current.Store(nil)
|
||||
a.current.StoreNoWB(nil)
|
||||
}
|
||||
a.dropping.Store(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user