]> Cypherpunks repositories - gostls13.git/commit
runtime: fix debug non-concurrent sweep mode after activeSweep changes
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 27 Mar 2023 15:47:18 +0000 (15:47 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 21 Jul 2023 00:28:09 +0000 (00:28 +0000)
commit4f4c23512e2d5cddfa7024a7e9c217ba357b9978
tree82a945eacc4a4bee1e7dc7f73a7c7072e5be4e03
parent16ec51471288f86d601efb9a2eb6b418cf634c16
runtime: fix debug non-concurrent sweep mode after activeSweep changes

Currently the GC creates a sweepLocker before restarting the world at
the end of the mark phase, so that it can safely flush mcaches without
the runtime incorrectly concluding that sweeping is done before that
happens.

However, with GODEBUG=gcstoptheworld=2, where sweeping happens during
that STW phase, creating that sweepLocker will fail, since the runtime
will conclude that sweeping is in fact complete (all the queues will be
drained). The problem however is that gcSweep, which does the
non-concurrent sweeping, doesn't actually flush mcaches.

In essence, this failure to create a sweepLocker is indicating a real
issue: sweeping is marked as complete, but we haven't flush the mcaches
yet!

The fix to this is to flush mcaches in gcSweep when in a non-concurrent
sweep. Now that gcSweep actually completes a full sweep, it's safe to
ignore a failure to create a sweepLocker (and in fact, it *must* fail).

While we're here, let's also remove _ConcurrentSweep, the debug flag.
There's already an alias for it called concurrentSweep, and there's only
one use of it in gcSweep.

Lastly, add a dist test for the GODEBUG=gcstoptheworld=2 mode.

Fixes #53885.

Change-Id: I8a1e5b8f362ed8abd03f76e4950d3211f145ab1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/479517
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/dist/test.go
src/runtime/malloc.go
src/runtime/mgc.go