From: Michael Anthony Knyszek Date: Mon, 12 Apr 2021 22:40:36 +0000 (+0000) Subject: runtime: track scannable globals space X-Git-Tag: go1.18beta1~674 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9da64156a62e4661fb5b0e64a2f196f253ce0dc5;p=gostls13.git runtime: track scannable globals space For #44167. Change-Id: I2cd13229d88f630451fabd113b0e5a04841e9e79 Reviewed-on: https://go-review.googlesource.com/c/go/+/309590 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 9cc7cf99db..ad7c4bb840 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -182,6 +182,12 @@ type gcControllerState struct { // Read and updated atomically. scannableStackSize uint64 + // globalsScan is the total amount of global variable space + // that is scannable. + // + // Read and updated atomically. + globalsScan uint64 + // heapMarked is the number of bytes marked by the previous // GC. After mark termination, heapLive == heapMarked, but // unlike heapLive, heapMarked does not change until the @@ -715,6 +721,10 @@ func (c *gcControllerState) addScannableStack(pp *p, amount int64) { } } +func (c *gcControllerState) addGlobals(amount int64) { + atomic.Xadd64(&c.globalsScan, amount) +} + // commit sets the trigger ratio and updates everything // derived from it: the absolute trigger, the heap goal, mark pacing, // and sweep pacing. diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index 41161d6f90..3237a6b708 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -529,8 +529,11 @@ func modulesinit() { } *modules = append(*modules, md) if md.gcdatamask == (bitvector{}) { - md.gcdatamask = progToPointerMask((*byte)(unsafe.Pointer(md.gcdata)), md.edata-md.data) - md.gcbssmask = progToPointerMask((*byte)(unsafe.Pointer(md.gcbss)), md.ebss-md.bss) + scanDataSize := md.edata - md.data + md.gcdatamask = progToPointerMask((*byte)(unsafe.Pointer(md.gcdata)), scanDataSize) + scanBSSSize := md.ebss - md.bss + md.gcbssmask = progToPointerMask((*byte)(unsafe.Pointer(md.gcbss)), scanBSSSize) + gcController.addGlobals(int64(scanDataSize + scanBSSSize)) } }