mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: hold traceAcquire across casgstatus in injectglist
Currently injectglist emits all the trace events before actually calling casgstatus on each goroutine. This is a problem, since tracing can observe an inconsistent state (gstatus does not match tracer's 'emitted an event' state). This change fixes the problem by having injectglist do what every other scheduler function does, and that's wrap each call to casgstatus in traceAcquire/traceRelease. Fixes #70883. Change-Id: I857e96cec01688013597e8efc0c4c3d0b72d3a70 Reviewed-on: https://go-review.googlesource.com/c/go/+/638558 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
1e9835f5b1
commit
f025d19e7b
1 changed files with 7 additions and 7 deletions
|
|
@ -3894,23 +3894,23 @@ func injectglist(glist *gList) {
|
||||||
if glist.empty() {
|
if glist.empty() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
trace := traceAcquire()
|
|
||||||
if trace.ok() {
|
|
||||||
for gp := glist.head.ptr(); gp != nil; gp = gp.schedlink.ptr() {
|
|
||||||
trace.GoUnpark(gp, 0)
|
|
||||||
}
|
|
||||||
traceRelease(trace)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark all the goroutines as runnable before we put them
|
// Mark all the goroutines as runnable before we put them
|
||||||
// on the run queues.
|
// on the run queues.
|
||||||
head := glist.head.ptr()
|
head := glist.head.ptr()
|
||||||
var tail *g
|
var tail *g
|
||||||
qsize := 0
|
qsize := 0
|
||||||
|
trace := traceAcquire()
|
||||||
for gp := head; gp != nil; gp = gp.schedlink.ptr() {
|
for gp := head; gp != nil; gp = gp.schedlink.ptr() {
|
||||||
tail = gp
|
tail = gp
|
||||||
qsize++
|
qsize++
|
||||||
casgstatus(gp, _Gwaiting, _Grunnable)
|
casgstatus(gp, _Gwaiting, _Grunnable)
|
||||||
|
if trace.ok() {
|
||||||
|
trace.GoUnpark(gp, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if trace.ok() {
|
||||||
|
traceRelease(trace)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn the gList into a gQueue.
|
// Turn the gList into a gQueue.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue