]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: ensure elapsed cycles are not negative
authorPeter Weinberger <pjw@google.com>
Fri, 28 Oct 2016 19:12:18 +0000 (15:12 -0400)
committerPeter Weinberger <pjw@google.com>
Fri, 28 Oct 2016 22:14:10 +0000 (22:14 +0000)
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>
src/runtime/mprof.go

index b3452f2c879b8a650aa325e27389919550a7e932..fc06d8dbe758866bd62cbfb0baa4c90840e65aaa 100644 (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()