diff options
| author | Michael Pratt <mpratt@google.com> | 2025-10-24 14:54:21 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-11-11 13:29:58 -0800 |
| commit | 2263d4aabdde8a4a466009ecc356501f87c7efb7 (patch) | |
| tree | 57120a24932233dd9925313fd01ef68b9e3a5856 /src/runtime/proc.go | |
| parent | 046dce0e5435f726cec46683ecb92cc852c136f8 (diff) | |
| download | go-2263d4aabdde8a4a466009ecc356501f87c7efb7.tar.xz | |
runtime: doubly-linked sched.midle list
This will be used by CL 714801 to remove Ms from the middle of the list.
We could simply convert schedlink to the doubly-linked list, bringing
along all other uses of schedlink.
However, CL 714801 removes Ms from the middle of the midle list. It
would be an easy mistake to make to accidentally remove an M from
schedlink, assuming that it is on the midle list when it is actually on
a completely different list. Using separate a list node makes this
impossible.
For #65694.
Change-Id: I6a6a636c223d925fdc30c0c648460cbf5c2af4d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/714800
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/proc.go')
| -rw-r--r-- | src/runtime/proc.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 91740d1fa6..30d2a68626 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -849,6 +849,8 @@ func schedinit() { lockVerifyMSize() + sched.midle.init(unsafe.Offsetof(m{}.idleNode)) + // raceinit must be the first call to race detector. // In particular, it must be done before mallocinit below calls racemapshadow. gp := getg() @@ -6976,8 +6978,7 @@ func schedEnabled(gp *g) bool { func mput(mp *m) { assertLockHeld(&sched.lock) - mp.schedlink = sched.midle - sched.midle.set(mp) + sched.midle.push(unsafe.Pointer(mp)) sched.nmidle++ checkdead() } @@ -6990,9 +6991,8 @@ func mput(mp *m) { func mget() *m { assertLockHeld(&sched.lock) - mp := sched.midle.ptr() + mp := (*m)(sched.midle.pop()) if mp != nil { - sched.midle = mp.schedlink sched.nmidle-- } return mp |
