Commit a1b6e169 authored by Peter Weinberger's avatar Peter Weinberger

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/32258Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent ec5b6406
...@@ -346,6 +346,9 @@ func SetMutexProfileFraction(rate int) int { ...@@ -346,6 +346,9 @@ func SetMutexProfileFraction(rate int) int {
//go:linkname mutexevent sync.event //go:linkname mutexevent sync.event
func mutexevent(cycles int64, skip int) { func mutexevent(cycles int64, skip int) {
if cycles < 0 {
cycles = 0
}
rate := int64(atomic.Load64(&mutexprofilerate)) rate := int64(atomic.Load64(&mutexprofilerate))
// TODO(pjw): measure impact of always calling fastrand vs using something // TODO(pjw): measure impact of always calling fastrand vs using something
// like malloc.go:nextSample() // like malloc.go:nextSample()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment