1
0
mirror of https://github.com/golang/go synced 2024-09-30 03:34:51 -06:00

runtime: ensure elapsed cycles are not negative

On solaris/amd64 sometimes the reported cycle count is negative. Replace
with 0.

Change-Id: I364eea5ca072281245c7ab3afb0bf69adc3a8eae
Reviewed-on: https://go-review.googlesource.com/32258
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Peter Weinberger 2016-10-28 15:12:18 -04:00
parent ec5b6406b7
commit a1b6e1692b

View File

@ -346,6 +346,9 @@ func SetMutexProfileFraction(rate int) int {
//go:linkname mutexevent sync.event
func mutexevent(cycles int64, skip int) {
if cycles < 0 {
cycles = 0
}
rate := int64(atomic.Load64(&mutexprofilerate))
// TODO(pjw): measure impact of always calling fastrand vs using something
// like malloc.go:nextSample()