]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: convert worldIsStopped to atomic type
authorcuiweixie <cuiweixie@gmail.com>
Fri, 26 Aug 2022 02:41:32 +0000 (10:41 +0800)
committerMichael Pratt <mpratt@google.com>
Wed, 31 Aug 2022 17:15:13 +0000 (17:15 +0000)
For #53821

Change-Id: I246b65ddb1171d2cab42f98092c64f20ecef392a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425778
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/lockrank_on.go

index 23adad7660dc6da4113a074fd9543e0efcb67da1..5dcc79b15eb85d3429e319a3a660714795c5e1a3 100644 (file)
@@ -13,7 +13,7 @@ import (
 
 // worldIsStopped is accessed atomically to track world-stops. 1 == world
 // stopped.
-var worldIsStopped uint32
+var worldIsStopped atomic.Uint32
 
 // lockRankStruct is embedded in mutex
 type lockRankStruct struct {
@@ -301,7 +301,7 @@ func assertRankHeld(r lockRank) {
 //
 //go:nosplit
 func worldStopped() {
-       if stopped := atomic.Xadd(&worldIsStopped, 1); stopped != 1 {
+       if stopped := worldIsStopped.Add(1); stopped != 1 {
                systemstack(func() {
                        print("world stop count=", stopped, "\n")
                        throw("recursive world stop")
@@ -317,7 +317,7 @@ func worldStopped() {
 //
 //go:nosplit
 func worldStarted() {
-       if stopped := atomic.Xadd(&worldIsStopped, -1); stopped != 0 {
+       if stopped := worldIsStopped.Add(-1); stopped != 0 {
                systemstack(func() {
                        print("world stop count=", stopped, "\n")
                        throw("released non-stopped world stop")
@@ -329,7 +329,7 @@ func worldStarted() {
 //
 //go:nosplit
 func checkWorldStopped() bool {
-       stopped := atomic.Load(&worldIsStopped)
+       stopped := worldIsStopped.Load()
        if stopped > 1 {
                systemstack(func() {
                        print("inconsistent world stop count=", stopped, "\n")