golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/trace/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 // Code generated by "gen.bash" from internal/trace/v2; DO NOT EDIT. 6 7 //go:build go1.21 8 9 // Tests syscall P stealing at a generation boundary. 10 11 package main 12 13 import ( 14 "golang.org/x/exp/trace" 15 "golang.org/x/exp/trace/internal/event/go122" 16 testgen "golang.org/x/exp/trace/internal/testgen/go122" 17 ) 18 19 func main() { 20 testgen.Main(gen) 21 } 22 23 func gen(t *testgen.Trace) { 24 g := t.Generation(1) 25 26 // One goroutine is exiting with a syscall. It already 27 // acquired a new P. 28 b0 := g.Batch(trace.ThreadID(0), 0) 29 b0.Event("ProcStatus", trace.ProcID(1), go122.ProcRunning) 30 b0.Event("GoStatus", trace.GoID(1), trace.ThreadID(0), go122.GoSyscall) 31 b0.Event("GoSyscallEndBlocked") 32 33 // A bare M stole the goroutine's P at the generation boundary. 34 b1 := g.Batch(trace.ThreadID(1), 0) 35 b1.Event("ProcStatus", trace.ProcID(0), go122.ProcSyscallAbandoned) 36 b1.Event("ProcSteal", trace.ProcID(0), testgen.Seq(1), trace.ThreadID(0)) 37 }