mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Change gopark()'s fourth argument type to traceBlockReason.
This follows https://go-review.googlesource.com/c/go/+/494185. PiperOrigin-RevId: 586109546
This commit is contained in:
@@ -206,7 +206,7 @@ func (s *Sleeper) nextWaker(block, wakepOrSleep bool) *Waker {
|
||||
// See:runtime2.go in the go runtime package for
|
||||
// the values to pass as the waitReason here.
|
||||
const waitReasonSelect = 9
|
||||
sync.Gopark(commitSleep, unsafe.Pointer(&s.waitingG), sync.WaitReasonSelect, sync.TraceEvGoBlockSelect, 0)
|
||||
sync.Gopark(commitSleep, unsafe.Pointer(&s.waitingG), sync.WaitReasonSelect, sync.TraceBlockSelect, 0)
|
||||
}
|
||||
|
||||
// Pull the shared list out and reverse it in the local
|
||||
|
||||
@@ -27,6 +27,7 @@ go_library(
|
||||
"runtime.go",
|
||||
"runtime_amd64.go",
|
||||
"runtime_constants.go",
|
||||
"runtime_exectracer1.go",
|
||||
"runtime_go121_unsafe.go",
|
||||
"runtime_not_go121_unsafe.go",
|
||||
"runtime_other.go",
|
||||
|
||||
@@ -140,8 +140,8 @@ func (g *Gate) Close() {
|
||||
// The last call to Leave arrived while we were setting up closingG.
|
||||
return
|
||||
}
|
||||
// WaitReasonSemacquire/TraceEvGoBlockSync are consistent with WaitGroup.
|
||||
gopark(gateCommit, gohacks.Noescape(unsafe.Pointer(&g.closingG)), WaitReasonSemacquire, TraceEvGoBlockSync, 0)
|
||||
// WaitReasonSemacquire/TraceBlockSync are consistent with WaitGroup.
|
||||
gopark(gateCommit, gohacks.Noescape(unsafe.Pointer(&g.closingG)), WaitReasonSemacquire, TraceBlockSync, 0)
|
||||
}
|
||||
|
||||
//go:norace
|
||||
|
||||
@@ -20,10 +20,3 @@ const (
|
||||
WaitReasonChanReceive uint8 = 14 // +checkconst runtime waitReasonChanReceive
|
||||
WaitReasonSemacquire uint8 = 18 // +checkconst runtime waitReasonSemacquire
|
||||
)
|
||||
|
||||
// Values for the traceEv argument to gopark, from Go's src/runtime/trace.go.
|
||||
const (
|
||||
TraceEvGoBlockRecv byte = 23 // +checkconst runtime traceEvGoBlockRecv
|
||||
TraceEvGoBlockSelect byte = 24 // +checkconst runtime traceEvGoBlockSelect
|
||||
TraceEvGoBlockSync byte = 25 // +checkconst runtime traceEvGoBlockSync
|
||||
)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2023 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package sync
|
||||
|
||||
// TraceBlockReason constants, from Go's src/runtime/trace.go.
|
||||
const (
|
||||
TraceBlockSelect TraceBlockReason = traceEvGoBlockSelect // +checkconst runtime traceBlockSelect
|
||||
TraceBlockSync = traceEvGoBlockSync // +checkconst runtime traceBlockSync
|
||||
)
|
||||
|
||||
// Tracer event types, from Go's src/runtime/trace.go.
|
||||
const (
|
||||
traceEvGoBlockSelect = 24 // +checkconst runtime traceEvGoBlockSelect
|
||||
traceEvGoBlockSync = 25 // +checkconst runtime traceEvGoBlockSync
|
||||
)
|
||||
@@ -29,12 +29,15 @@ func Goyield() {
|
||||
// splitting and race context are not available where it is called.
|
||||
//
|
||||
//go:nosplit
|
||||
func Gopark(unlockf func(uintptr, unsafe.Pointer) bool, lock unsafe.Pointer, reason uint8, traceEv byte, traceskip int) {
|
||||
gopark(unlockf, lock, reason, traceEv, traceskip)
|
||||
func Gopark(unlockf func(uintptr, unsafe.Pointer) bool, lock unsafe.Pointer, reason uint8, traceReason TraceBlockReason, traceskip int) {
|
||||
gopark(unlockf, lock, reason, traceReason, traceskip)
|
||||
}
|
||||
|
||||
//go:linkname gopark runtime.gopark
|
||||
func gopark(unlockf func(uintptr, unsafe.Pointer) bool, lock unsafe.Pointer, reason uint8, traceEv byte, traceskip int)
|
||||
func gopark(unlockf func(uintptr, unsafe.Pointer) bool, lock unsafe.Pointer, reason uint8, traceReason TraceBlockReason, traceskip int)
|
||||
|
||||
// TraceBlockReason is equivalent to runtime.traceBlockReason.
|
||||
type TraceBlockReason uint8
|
||||
|
||||
//go:linkname wakep runtime.wakep
|
||||
func wakep()
|
||||
|
||||
@@ -93,7 +93,7 @@ func (w *Waiter) WaitFor(es Set) Set {
|
||||
// If w.g is still preparingG (i.e. w.NotifyPending() has not been
|
||||
// called or has not reached atomic.SwapUintptr()), go to sleep until
|
||||
// w.NotifyPending() => goready().
|
||||
sync.Gopark(waiterCommit, unsafe.Pointer(&w.g), sync.WaitReasonSelect, sync.TraceEvGoBlockSelect, 0)
|
||||
sync.Gopark(waiterCommit, unsafe.Pointer(&w.g), sync.WaitReasonSelect, sync.TraceBlockSelect, 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (w *Waiter) WaitAndAckAll() Set {
|
||||
// If w.g is still preparingG (i.e. w.NotifyPending() has not been
|
||||
// called or has not reached atomic.SwapUintptr()), go to sleep until
|
||||
// w.NotifyPending() => goready().
|
||||
sync.Gopark(waiterCommit, unsafe.Pointer(&w.g), sync.WaitReasonSelect, sync.TraceEvGoBlockSelect, 0)
|
||||
sync.Gopark(waiterCommit, unsafe.Pointer(&w.g), sync.WaitReasonSelect, sync.TraceBlockSelect, 0)
|
||||
|
||||
// Check for pending events. We call PendingAndAckAll() directly now since
|
||||
// we only expect to be woken after events become pending.
|
||||
|
||||
Reference in New Issue
Block a user