[go] runtime: eliminate _Psyscall

1 view
Skip to first unread message

Michael Knyszek (Gerrit)

unread,
Oct 1, 2025, 5:37:40 PM (11 hours ago) Oct 1
to goph...@pubsubhelper.golang.org, Michael Pratt, Go LUCI, Austin Clements, Cherry Mui, Ian Lance Taylor, golang-co...@googlegroups.com
Attention needed from Austin Clements, Cherry Mui, Ian Lance Taylor and Michael Pratt

Michael Knyszek added 12 comments

File src/runtime/heapdump.go
File src/runtime/mprof.go
Line 1482, Patchset 15: // Double-check that we didn't make a grave mistake. If the G is running and not
// coming out of a syscall, then we cannot safely read its stack.
//
Michael Pratt . resolved

This is fine in the context of reading this CL, but I think out of context it could be cryptic. I think this should explicitly mention the window in exitsyscall where we are Grunning without a P.

Michael Knyszek

Done

File src/runtime/proc.go
Line 4747, Patchset 15: // Careful: once we enter _Gsyscall, our M's P wiring is no longer ours to modify.
Michael Pratt . unresolved

Isn't this irrelevant? The P is already gone.

Instead this should probably be a warning about the small window of _Grunning without a P.

Also, while I'm not sure about permanent testing, you could do some one-off testing by adding some spinning here to increase the probability of others observing a G in this state.

Michael Knyszek

fixed the comment, leaving open for testing

Line 4809, Patchset 15:
Michael Pratt . resolved

Oh, another window, fun!

Michael Knyszek

this one is the more problematic one in general, it seems. luckily there seems to be very little that relies on an invariant like a running G having a P, since readgstatus' result is always slightly in the past. you can't assume it has a P.

(suspendG assumes it has an M, but that's fine. goroutine profiling cares, but only for a runtime assertion. but who knows, there may be more.)

Line 4837, Patchset 15: // lost our P or not (determined by exitsyscallfast).
Michael Pratt . resolved

update

Michael Knyszek

Done

Line 4841, Patchset 15: // Trace that we're starting again, because there was a tracev2.GoSysBlock
Michael Pratt . resolved

Oops, tracev2.GoSysBlock doesn't even exist.

Michael Knyszek

Done

Line 4865, Patchset 15: if sched.stopwait == freezeStopWait || (sched.disable.user && !schedEnabled(gp)) {
Michael Pratt . resolved

Why add this? It seems reasonable, I'm wondering why it wasn't here before.

Michael Knyszek

I... don't remember why I added this. I'll move it into a follow-up CL.

Line 6426, Patchset 15 (Parent): incidlelocked(-1)
Michael Pratt . resolved

This is no longer necessary because exitsyscall can't reach mput until after we resume, right?

Michael Knyszek

hm, on second thought, this may still be necessary unless we call handoffp before resuming? I'm thinking like:

sysmon: stop T1 in _Gsyscall
sysmon: take T1's P
sysmon: resume T1
T1: exitsyscallNoP -> stopm -> mput (everything is idle)

I added it back in.

Line 6460, Patchset 15: if status != _Gsyscall && status != _Gextra {
Michael Pratt . resolved

Why does this continue for extra M Gs?

Michael Knyszek

added a comment. it's because extra M Gs might have a P attached to them. it's like an extension of the syscall state.

File src/runtime/runtime2.go
Line 45, Patchset 15: // It is assigned an M and a P (g.m and g.m.p are valid).
Michael Pratt . resolved

Note that it might not have a P (when observed externally).

Michael Knyszek

Done

Line 50, Patchset 15: // goroutine. It is not on a run queue. It is assigned an M.
Michael Pratt . resolved

Note that it might not have a P.

Michael Knyszek

Done

Line 546, Patchset 15: // p is the currently atttached P for executing Go code, nil if not executing user Go code.
Michael Pratt . resolved

attached

Michael Knyszek

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Austin Clements
  • Cherry Mui
  • Ian Lance Taylor
  • Michael Pratt
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4551afc1eea0c1b67a0b2dd26b0d49aa47bf1fb8
Gerrit-Change-Number: 646198
Gerrit-PatchSet: 31
Gerrit-Owner: Michael Knyszek <mkny...@google.com>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-CC: Austin Clements <aus...@google.com>
Gerrit-CC: Cherry Mui <cher...@google.com>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Michael Pratt <mpr...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Comment-Date: Wed, 01 Oct 2025 21:37:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Michael Pratt <mpr...@google.com>
unsatisfied_requirement
open
diffy

Michael Knyszek (Gerrit)

unread,
Oct 1, 2025, 5:37:44 PM (11 hours ago) Oct 1
to goph...@pubsubhelper.golang.org, Michael Pratt, Go LUCI, Austin Clements, Cherry Mui, Ian Lance Taylor, golang-co...@googlegroups.com
Attention needed from Austin Clements, Cherry Mui, Ian Lance Taylor and Michael Pratt

Michael Knyszek voted Commit-Queue+1

Commit-Queue+1
Gerrit-Comment-Date: Wed, 01 Oct 2025 21:37:41 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy

Michael Knyszek (Gerrit)

unread,
Oct 1, 2025, 7:56:22 PM (8 hours ago) Oct 1
to goph...@pubsubhelper.golang.org, Go LUCI, Michael Pratt, Austin Clements, Cherry Mui, Ian Lance Taylor, golang-co...@googlegroups.com
Attention needed from Austin Clements, Cherry Mui, Ian Lance Taylor and Michael Pratt

Michael Knyszek voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Austin Clements
  • Cherry Mui
  • Ian Lance Taylor
  • Michael Pratt
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4551afc1eea0c1b67a0b2dd26b0d49aa47bf1fb8
Gerrit-Change-Number: 646198
Gerrit-PatchSet: 32
Gerrit-Owner: Michael Knyszek <mkny...@google.com>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-CC: Austin Clements <aus...@google.com>
Gerrit-CC: Cherry Mui <cher...@google.com>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Michael Pratt <mpr...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Comment-Date: Wed, 01 Oct 2025 23:56:19 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages