aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/trace2stack.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/trace2stack.go')
-rw-r--r--src/runtime/trace2stack.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/runtime/trace2stack.go b/src/runtime/trace2stack.go
index 7d698c89d3..4ee3b32b05 100644
--- a/src/runtime/trace2stack.go
+++ b/src/runtime/trace2stack.go
@@ -138,6 +138,11 @@ func (t *traceStackTable) put(pcs []uintptr) uint64 {
// dump writes all previously cached stacks to trace buffers,
// releases all memory and resets state. It must only be called once the caller
// can guarantee that there are no more writers to the table.
+//
+// This must run on the system stack because it flushes buffers and thus
+// may acquire trace.lock.
+//
+//go:systemstack
func (t *traceStackTable) dump(gen uintptr) {
w := unsafeTraceWriter(gen, nil)
@@ -189,11 +194,9 @@ func (t *traceStackTable) dump(gen uintptr) {
}
// Still, hold the lock over reset. The callee expects it, even though it's
// not strictly necessary.
- systemstack(func() {
- lock(&t.tab.lock)
- t.tab.reset()
- unlock(&t.tab.lock)
- })
+ lock(&t.tab.lock)
+ t.tab.reset()
+ unlock(&t.tab.lock)
w.flush().end()
}