dd5db4df56
When a thread transitions to spinning to non-spinning it must recheck all sources of work because other threads may submit new work but skip wakep because they see a spinning thread. However, since the beginning of time (CL 7314062) we do not check the global run queue, only the local per-P run queues. The global run queue is checked just above the spinning checks while dropping the P. I am unsure what the purpose of this check is. It appears to simply be opportunistic since sched.lock is already held there in order to drop the P. It is not sufficient to synchronize with threads adding work because it occurs before decrementing sched.nmspinning, which is what threads us to decide to wake a thread. Resolve this by adding an explicit global run queue check alongside the local per-P run queue checks. Almost nothing happens between dropped sched.lock after dropping the P and relocking sched.lock: just clearing mp.spinning and decrementing sched.nmspinning. Thus it may be better to just hold sched.lock for this entire period, but this is a larger change that I would prefer to avoid in the freeze and backports. For #55160. Change-Id: Ifd88b5a4c561c063cedcfcfe1dd8ae04202d9666 Reviewed-on: https://go-review.googlesource.com/c/go/+/501975 Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> |
||
---|---|---|
.github | ||
api | ||
doc | ||
lib/time | ||
misc | ||
src | ||
test | ||
.gitattributes | ||
.gitignore | ||
codereview.cfg | ||
CONTRIBUTING.md | ||
go.env | ||
LICENSE | ||
PATENTS | ||
README.md | ||
SECURITY.md |
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.