Skip to content

Commit 7a8d0b5

Browse files
mknyszekgopherbot
authored andcommitted
runtime: add debug mode to extend _Grunning-without-P windows
This was suggested in CL 646198, and I tested with it, I forgot to push it so it wasn't merged. I think it might be worth keeping. Change-Id: Ibf97d969fe7d0eeb365f5f7b1fbeadea3a1076ab Reviewed-on: https://go-review.googlesource.com/c/go/+/716580 Reviewed-by: Cherry Mui <[email protected]> Auto-Submit: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 710abf7 commit 7a8d0b5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/runtime/proc.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4658,6 +4658,11 @@ func reentersyscall(pc, sp, bp uintptr) {
46584658
gp.m.locks--
46594659
}
46604660

4661+
// debugExtendGrunningNoP is a debug mode that extends the windows in which
4662+
// we're _Grunning without a P in order to try to shake out bugs with code
4663+
// assuming this state is impossible.
4664+
const debugExtendGrunningNoP = false
4665+
46614666
// Standard syscall entry used by the go syscall library and normal cgo calls.
46624667
//
46634668
// This is exported via linkname to assembly in the syscall package and x/sys.
@@ -4770,6 +4775,9 @@ func entersyscallblock() {
47704775
// <--
47714776
// Caution: we're in a small window where we are in _Grunning without a P.
47724777
// -->
4778+
if debugExtendGrunningNoP {
4779+
usleep(10)
4780+
}
47734781
casgstatus(gp, _Grunning, _Gsyscall)
47744782
if gp.syscallsp < gp.stack.lo || gp.stack.hi < gp.syscallsp {
47754783
systemstack(func() {
@@ -4852,6 +4860,9 @@ func exitsyscall() {
48524860
// Caution: we're in a window where we may be in _Grunning without a P.
48534861
// Either we will grab a P or call exitsyscall0, where we'll switch to
48544862
// _Grunnable.
4863+
if debugExtendGrunningNoP {
4864+
usleep(10)
4865+
}
48554866

48564867
// Grab and clear our old P.
48574868
oldp := gp.m.oldp.ptr()

0 commit comments

Comments
 (0)