aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2025-12-11 02:51:27 +0000
committerMichael Knyszek <mknyszek@google.com>2025-12-11 08:36:19 -0800
commit1de9585be24aaa11ecc79a5fe976713b8e7fd446 (patch)
tree6a01a75e623b9efc382b5cc9600e875cab8525df /src/encoding
parente38c38f0e539f599216247b5293d5c78aa82468b (diff)
downloadgo-1de9585be24aaa11ecc79a5fe976713b8e7fd446.tar.xz
runtime: prevent calls to GOMAXPROCS while clearing P trace state
Currently, between the forEachP that ensures every P has a status in the trace and readying dead Ps for the next generation, there's a big window where GOMAXPROCS could run and change the number of Ps. In such circumstances, P state will not get properly prepared for the next generation, and we may fail to emit a status for a P. This change addresses the problem by holding worldsema across both operations. It also moves the status emission and state clearing to before the generation transition because that makes the code *much* clearer. Currently we do both these things after the generation transition targeting the next-next generation. The reason for this is to avoid an extra forEachP (because we already handle P status in the STW for enabling tracing to begin with) but approach is just plain harder to reason about. Preparing the next generation before transitioning to it, like we do for goroutines, is much clearer. Furthermore, we also need to set up the dead P state even if we're stopping the trace, which would mean duplicating code into both branches (if stopping the trace, then we go non-preemptible, otherwise we do it under worldsema) which is also less clear. Note that with this change we no longer need to emit the P statuses during the STW, which was probably the worse choice anyway, since holding up the STW for an O(P) operation is worse than a forEachP we're going to do anyway. So, this change does away with that too. Fixes #76572. Change-Id: Ie7908adff43a8a372cae432bcc2f4e0d6a87d7bc Reviewed-on: https://go-review.googlesource.com/c/go/+/729023 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/encoding')
0 files changed, 0 insertions, 0 deletions