aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mprof.go
diff options
context:
space:
mode:
authorPeter Weinberger <pjw@google.com>2016-10-28 15:12:18 -0400
committerPeter Weinberger <pjw@google.com>2016-10-28 22:14:10 +0000
commita1b6e1692b063488cfcc51c258b159ccce4f7d23 (patch)
tree8210191abf5c27e1029b37227650645c610b5995 /src/runtime/mprof.go
parentec5b6406b76462a1a97ce19f86c5c23ac1d2c830 (diff)
downloadgo-a1b6e1692b063488cfcc51c258b159ccce4f7d23.tar.gz
go-a1b6e1692b063488cfcc51c258b159ccce4f7d23.zip
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>
Diffstat (limited to 'src/runtime/mprof.go')
-rw-r--r--src/runtime/mprof.go3
1 files changed, 3 insertions, 0 deletions
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()