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. 6 7package main 8 9import ( 10 "internal/trace" 11 "internal/trace/event/go122" 12 testgen "internal/trace/internal/testgen/go122" 13) 14 15func main() { 16 testgen.Main(gen) 17} 18 19func gen(t *testgen.Trace) { 20 g := t.Generation(1) 21 22 // One goroutine enters a syscall. 23 b0 := g.Batch(trace.ThreadID(0), 0) 24 b0.Event("ProcStatus", trace.ProcID(0), go122.ProcRunning) 25 b0.Event("GoStatus", trace.GoID(1), trace.ThreadID(0), go122.GoRunning) 26 b0.Event("GoSyscallBegin", testgen.Seq(1), testgen.NoStack) 27 b0.Event("GoSyscallEndBlocked") 28 29 // A bare M steals the goroutine's P. 30 b1 := g.Batch(trace.ThreadID(1), 0) 31 b1.Event("ProcSteal", trace.ProcID(0), testgen.Seq(2), trace.ThreadID(0)) 32} 33