]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: make all GC mark workers yield for forEachP
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 23 Oct 2023 19:30:35 +0000 (19:30 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 9 Nov 2023 22:38:21 +0000 (22:38 +0000)
commit25895d1c995d71ca505e1e7a3c79daa49620db74
treec4417414a10383c875286d02298d4847d385198f
parentff7cf2d4cd8289111e7cef36c8ad50f557b29311
runtime: make all GC mark workers yield for forEachP

Currently dedicated GC mark workers really try to avoid getting
preempted. The one exception is for a pending STW, indicated by
sched.gcwaiting. This is currently fine because other kinds of
preemptions don't matter to the mark workers: they're intentionally
bound to their P.

With the new execution tracer we're going to want to use forEachP to get
the attention of all Ps. We may want to do this during a GC cycle.
forEachP doesn't set sched.gcwaiting, so it may end up waiting the full
GC mark phase, burning a thread and a P in the meantime. This can mean
basically seconds of waiting and trying to preempt GC mark workers.

This change makes all mark workers yield if (*p).runSafePointFn != 0 so
that the workers actually yield somewhat promptly in response to a
forEachP attempt.

Change-Id: I7430baf326886b9f7a868704482a224dae7c9bba
Reviewed-on: https://go-review.googlesource.com/c/go/+/537235
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
src/runtime/mgcmark.go