From: Peter Weinberger Date: Fri, 28 Oct 2016 19:12:18 +0000 (-0400) Subject: runtime: ensure elapsed cycles are not negative X-Git-Tag: go1.8beta1~474 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a1b6e1692b063488cfcc51c258b159ccce4f7d23;p=gostls13.git 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 --- diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go index b3452f2c87..fc06d8dbe7 100644 --- a/src/runtime/mprof.go +++ b/src/runtime/mprof.go @@ -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()