diff options
Diffstat (limited to 'src/runtime/lock_spinbit.go')
| -rw-r--r-- | src/runtime/lock_spinbit.go | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/runtime/lock_spinbit.go b/src/runtime/lock_spinbit.go index 039ea6f565..590be8a0c5 100644 --- a/src/runtime/lock_spinbit.go +++ b/src/runtime/lock_spinbit.go @@ -327,16 +327,8 @@ func unlock2(l *mutex) { // mutexSampleContention returns whether the current mutex operation should // report any contention it discovers. func mutexSampleContention() bool { - if rate := int64(atomic.Load64(&mutexprofilerate)); rate <= 0 { - return false - } else { - // TODO: have SetMutexProfileFraction do the clamping - rate32 := uint32(rate) - if int64(rate32) != rate { - rate32 = ^uint32(0) - } - return cheaprandn(rate32) == 0 - } + rate := atomic.Load64(&mutexprofilerate) + return rate > 0 && cheaprandu64()%rate == 0 } // unlock2Wake updates the list of Ms waiting on l, waking an M if necessary. |
