mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: add race annotations to metricsSema
metricsSema protects the metrics map. The map implementation is race instrumented regardless of which package is it called from. semacquire/semrelease are not automatically race instrumented, so we can trigger race false positives without manually annotating our lock acquire and release. See similar instrumentation on trace.shutdownSema and reflectOffs.lock. Fixes #53542. Change-Id: Ia3fd239ac860e037d09c7cb9c4ad267391e70705 Reviewed-on: https://go-review.googlesource.com/c/go/+/414517 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
bd1783e812
commit
d6481d5b96
2 changed files with 27 additions and 10 deletions
|
|
@ -312,9 +312,9 @@ func ReadMetricsSlow(memStats *MemStats, samplesp unsafe.Pointer, len, cap int)
|
|||
|
||||
// Initialize the metrics beforehand because this could
|
||||
// allocate and skew the stats.
|
||||
semacquire(&metricsSema)
|
||||
metricsLock()
|
||||
initMetrics()
|
||||
semrelease(&metricsSema)
|
||||
metricsUnlock()
|
||||
|
||||
systemstack(func() {
|
||||
// Read memstats first. It's going to flush
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue