]> Cypherpunks repositories - gostls13.git/commit
runtime: disable preemption in startm
authorMichael Pratt <mpratt@google.com>
Mon, 2 Nov 2020 21:34:51 +0000 (16:34 -0500)
committerMichael Pratt <mpratt@google.com>
Thu, 5 Nov 2020 19:22:02 +0000 (19:22 +0000)
commit370682ae98d7edc3ce9772d6d1d746df93ba9e6d
treed70758c24e19b90a400b77807168642319675317
parent06538fa723fc358462c5d7ae385b5b64ac76827b
runtime: disable preemption in startm

startm contains a critical section from when it takes ownership of a P
(either on function entry or call to pidleput) until it wakes the M
receiving the P. If preempted in this critical section, the owned P is
left in limbo. If preempted for a GC stop, there will be nothing to stop
the owned P and STW will wait forever.

golang.org/cl/232298 introduced the first call to startm that is not on
the system stack (via a wakep call), introducing the possibility of
preemption. Disable preemption in startm to ensure this remains
non-preemptible.

Since we're not always on the system stack anymore, we also need to be
careful in allocm.

Updates #42237

Change-Id: Icb95eef9eb262121856485316098331beea045da
Reviewed-on: https://go-review.googlesource.com/c/go/+/267257
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Trust: Michael Pratt <mpratt@google.com>
src/runtime/proc.go