Source file src/internal/trace/testdata/generators/go122-syscall-steal-proc-reacquire-new-proc-bare-m.go

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

View as plain text