mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: fix lock acquire cycles related to scavenge.lock
There are currently two edges in the lock cycle graph caused by scavenge.lock: with sched.lock and mheap_.lock. These edges appear because of the call to ready() and stack growths respectively. Furthermore, there's already an invariant in the code wherein mheap_.lock must be acquired before scavenge.lock, hence the cycle. The fix to this is to bring scavenge.lock higher in the lock cycle graph, such that sched.lock and mheap_.lock are only acquired once scavenge.lock is already held. To faciliate this change, we move scavenger waking outside of gcSetTriggerRatio such that it doesn't have to happen with the heap locked. Furthermore, we check scavenge generation numbers with the heap locked by using gopark instead of goparkunlock, and specify a function which aborts the park should there be any skew in generation count. Fixes #34047. Change-Id: I3519119214bac66375e2b1262b36ce376c820d12 Reviewed-on: https://go-review.googlesource.com/c/go/+/191977 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
f7a00c9906
commit
62e4156552
3 changed files with 45 additions and 29 deletions
|
|
@ -107,6 +107,7 @@ type mheap struct {
|
|||
scavengeRetainedBasis uint64
|
||||
scavengeBytesPerNS float64
|
||||
scavengeRetainedGoal uint64
|
||||
scavengeGen uint64 // incremented on each pacing update
|
||||
|
||||
// Page reclaimer state
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue