Skip to content

Commit 052c192

Browse files
committed
runtime: fix lock rank for work.spanSPMCs.lock
Currently this lock is treated like a leaf lock, but it's not one. It can acquire the globalAlloc lock via fixalloc and persistentalloc. This means we need to figure out where it can be acquired. In general, it can be acquired by any write barrier, which is already incredibly broad. AFAICT, it can't be acquired directly otherwise, except when destroying a spanSPMC during procresize, in which case we'll be holding sched.lock. Fixes #75916. Change-Id: I2da1f5b82c750bf4e8d6a8a562046b9a17fd44be Reviewed-on: https://go-review.googlesource.com/c/go/+/717500 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent bc5ffe5 commit 052c192

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/runtime/lockrank.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/mgc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ func gcinit() {
199199
lockInit(&work.assistQueue.lock, lockRankAssistQueue)
200200
lockInit(&work.strongFromWeak.lock, lockRankStrongFromWeakQueue)
201201
lockInit(&work.wbufSpans.lock, lockRankWbufSpans)
202+
lockInit(&work.spanSPMCs.lock, lockRankSpanSPMCs)
202203
lockInit(&gcCleanups.lock, lockRankCleanupQueue)
203204
}
204205

@@ -352,7 +353,7 @@ type workType struct {
352353
//
353354
// Only used if goexperiment.GreenTeaGC.
354355
spanSPMCs struct {
355-
lock mutex // no lock rank because it's a leaf lock (see mklockrank.go).
356+
lock mutex
356357
all *spanSPMC
357358
}
358359

src/runtime/mklockrank.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ defer,
196196
# xRegState allocator
197197
sched < xRegAlloc;
198198
199+
# spanSPMCs allocator and list
200+
WB, sched < spanSPMCs;
201+
199202
# Span allocator
200203
stackLarge,
201204
stackpool,
@@ -209,7 +212,7 @@ stackLarge,
209212
# Pinner bits might be freed by the span allocator.
210213
mheap, mspanSpecial < mheapSpecial;
211214
# Fixallocs
212-
mheap, mheapSpecial, xRegAlloc < globalAlloc;
215+
mheap, mheapSpecial, xRegAlloc, spanSPMCs < globalAlloc;
213216
214217
# Execution tracer events (with a P)
215218
hchan,

0 commit comments

Comments
 (0)