]> Cypherpunks repositories - gostls13.git/commit
runtime: move scheduling decisions by schedule into findrunnable
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 18 Mar 2022 23:59:12 +0000 (23:59 +0000)
committerMichael Knyszek <mknyszek@google.com>
Tue, 26 Apr 2022 22:09:34 +0000 (22:09 +0000)
commit13b18ec947c9589b47f058d7e7b95e60fcdb3fc9
tree1625e42a213b94cc51a4bd3b3c8d7e743bd18422
parente1b5f347e78c733bb0743df04c990e20f74bf188
runtime: move scheduling decisions by schedule into findrunnable

This change moves several scheduling decisions made by schedule into
findrunnable. The main motivation behind this change is the fact that
stopped Ms can't become dedicated or fractional GC workers. The main
reason for this is that when a stopped M wakes up, it stays in
findrunnable until it finds work, which means it will never consider GC
work. On that note, it'll also never consider becoming the trace reader,
either.

Another way of looking at it is that this change tries to make
findrunnable aware of more sources of work than it was before. With this
change, any M in findrunnable should be capable of becoming a GC worker,
resolving #44313. While we're here, let's also make more sources of
work, such as the trace reader, visible to handoffp, which should really
be checking all sources of work. With that, we also now correctly handle
the case where StopTrace is called from the last live M that is also
locked (#39004). stoplockedm calls handoffp to start a new M and handle
the work it cannot, and once we include the trace reader in that, we
ensure that the trace reader gets scheduled.

This change attempts to preserve the exact same ordering of work
checking to reduce its impact.

One consequence of this change is that upon entering schedule, some
sources of work won't be checked twice (i.e. the local and global
runqs, and timers) as they do now, which in some sense gives them a
lower priority than they had before.

Fixes #39004.
Fixes #44313.

Change-Id: I5d8b7f63839db8d9a3e47cdda604baac1fe615ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/393880
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/runtime/proc.go
src/runtime/trace.go