aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/mstkbar.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/runtime/mstkbar.go b/src/runtime/mstkbar.go
index 6f5b459853..1c1c2eaf0a 100644
--- a/src/runtime/mstkbar.go
+++ b/src/runtime/mstkbar.go
@@ -300,16 +300,26 @@ func setNextBarrierPC(pc uintptr) {
// This is necessary because a sigprof during barrier installation or
// removal could observe inconsistencies between the stkbar array and
// the stack itself and crash.
+//
+//go:nosplit
func gcLockStackBarriers(gp *g) {
+ acquirem()
for !atomic.Cas(&gp.stackLock, 0, 1) {
osyield()
}
}
+//go:nosplit
func gcTryLockStackBarriers(gp *g) bool {
- return atomic.Cas(&gp.stackLock, 0, 1)
+ mp := acquirem()
+ result := atomic.Cas(&gp.stackLock, 0, 1)
+ if !result {
+ releasem(mp)
+ }
+ return result
}
func gcUnlockStackBarriers(gp *g) {
atomic.Store(&gp.stackLock, 0)
+ releasem(getg().m)
}