]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix test of when a mutex is contended
authorRhys Hiltner <rhys.hiltner@gmail.com>
Tue, 8 Apr 2025 18:34:56 +0000 (11:34 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 22 Apr 2025 16:58:32 +0000 (09:58 -0700)
This is used only in tests that verify reports of runtime-internal mutex
contention.

For #66999
For #70602

Change-Id: I72cb1302d8ea0524f1182ec892f5c9a1923cddba
Reviewed-on: https://go-review.googlesource.com/c/go/+/667095
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
src/runtime/lock_spinbit.go

index ba5268abdd53bdaa2380984941f1d84c8564cca7..7b7bc651ad95897dd134cf6c0764bd108460487d 100644 (file)
@@ -143,7 +143,7 @@ func mutexPreferLowLatency(l *mutex) bool {
 }
 
 func mutexContended(l *mutex) bool {
-       return atomic.Loaduintptr(&l.key) > mutexLocked
+       return atomic.Loaduintptr(&l.key)&^mutexMMask != 0
 }
 
 func lock(l *mutex) {