github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/trace/v2/testdata/generators/go122-syscall-steal-proc-gen-boundary-bare-m.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Tests syscall P stealing at a generation boundary. 6 7 package main 8 9 import ( 10 "github.com/go-asm/go/trace/v2" 11 "github.com/go-asm/go/trace/v2/event/go122" 12 testgen "github.com/go-asm/go/trace/v2/github.com/go-asm/go/testgen/go122" 13 ) 14 15 func main() { 16 testgen.Main(gen) 17 } 18 19 func gen(t *testgen.Trace) { 20 g := t.Generation(1) 21 22 // One goroutine is exiting with a syscall. It already 23 // acquired a new P. 24 b0 := g.Batch(trace.ThreadID(0), 0) 25 b0.Event("ProcStatus", trace.ProcID(1), go122.ProcRunning) 26 b0.Event("GoStatus", trace.GoID(1), trace.ThreadID(0), go122.GoSyscall) 27 b0.Event("GoSyscallEndBlocked") 28 29 // A bare M stole the goroutine's P at the generation boundary. 30 b1 := g.Batch(trace.ThreadID(1), 0) 31 b1.Event("ProcStatus", trace.ProcID(0), go122.ProcSyscallAbandoned) 32 b1.Event("ProcSteal", trace.ProcID(0), testgen.Seq(1), trace.ThreadID(0)) 33 }