Skip to content

Commit 7c37249

Browse files
committed
runtime: make test for freezetheworld more precise
exitsyscallfast checks for freezetheworld, but does so only by checking if stopwait is positive. This can also happen during stoptheworld, which is harmless, but confusing. Shortly, it will be important that we get to the p.status cas even if stopwait is set. Hence, make this test more specific so it only triggers with freezetheworld and not other uses of stopwait. Change-Id: Ibb722cd8360c3ed5a9654482519e3ceb87a8274d Reviewed-on: https://go-review.googlesource.com/8205 Reviewed-by: Russ Cox <[email protected]>
1 parent 253ad67 commit 7c37249

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/runtime/proc1.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ func helpgc(nproc int32) {
208208
unlock(&sched.lock)
209209
}
210210

211+
// freezeStopWait is a large value that freezetheworld sets
212+
// sched.stopwait to in order to request that all Gs permanently stop.
213+
const freezeStopWait = 0x7fffffff
214+
211215
// Similar to stoptheworld but best-effort and can be called several times.
212216
// There is no reverse operation, used during crashing.
213217
// This function must not lock any mutexes.
@@ -220,7 +224,7 @@ func freezetheworld() {
220224
// so try several times
221225
for i := 0; i < 5; i++ {
222226
// this should tell the scheduler to not start any new goroutines
223-
sched.stopwait = 0x7fffffff
227+
sched.stopwait = freezeStopWait
224228
atomicstore(&sched.gcwaiting, 1)
225229
// this should stop running goroutines
226230
if !preemptall() {
@@ -1864,7 +1868,7 @@ func exitsyscallfast() bool {
18641868
_g_ := getg()
18651869

18661870
// Freezetheworld sets stopwait but does not retake P's.
1867-
if sched.stopwait != 0 {
1871+
if sched.stopwait == freezeStopWait {
18681872
_g_.m.mcache = nil
18691873
_g_.m.p = nil
18701874
return false

0 commit comments

Comments
 (0)