]> Cypherpunks repositories - gostls13.git/commit
runtime: set G wait reason more consistently
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 31 Aug 2022 18:21:48 +0000 (18:21 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 16 Sep 2022 16:32:29 +0000 (16:32 +0000)
commit686b38b5b27fe14318adfee57aac780c452fddd6
treecde4fef9ca40611f31ab85ae95f0cdf92cf812fa
parenta2c396ce00df96f66246aab7a63f3ce5b7ad8753
runtime: set G wait reason more consistently

Currently, wait reasons are set somewhat inconsistently. In a follow-up
CL, we're going to want to rely on the wait reason being there for
casgstatus, so the status quo isn't really going to work for that. Plus
this inconsistency means there are a whole bunch of cases where we could
be more specific about the G's status but aren't.

So, this change adds a new function, casGToWaiting which is like
casgstatus but also sets the wait reason. The goal is that by using this
API it'll be harder to forget to set a wait reason (or the lack thereof
will at least be explicit). This change then updates all casgstatus(gp,
..., _Gwaiting) calls to casGToWaiting(gp, ..., waitReasonX) instead.
For a number of these cases, we're missing a wait reason, and it
wouldn't hurt to add a wait reason for them, so this change also adds
those wait reasons.

For #49881.

Change-Id: Ia95e06ecb74ed17bb7bb94f1a362ebfe6bec1518
Reviewed-on: https://go-review.googlesource.com/c/go/+/427617
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/runtime/debugcall.go
src/runtime/heapdump.go
src/runtime/mgc.go
src/runtime/mgcmark.go
src/runtime/proc.go
src/runtime/runtime2.go