From 04772f022a1cb19f2596fa241ecc24bcb7f4dce5 Mon Sep 17 00:00:00 2001 From: Nick Ripley Date: Mon, 23 Feb 2026 15:46:04 +0000 Subject: 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt --- src/runtime/traceregion.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/traceregion.go b/src/runtime/traceregion.go index eb19294f1b..e3a024c458 100644 --- a/src/runtime/traceregion.go +++ b/src/runtime/traceregion.go @@ -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) } -- cgit v1.3-5-g9baa