mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
systrap: remove the subprocess list
It was used to disable the fast path in stub threads. The current implemenation has a race when subprocessList.PushBack(s) can be called before subprocessList.Remove(s). This issue can be fixed by introducing a new mutex to guard contextQueue.numAwakeContexts, but it will introduce additional overhead. It was an addition way to disable the stub fast path. We do the same thing when a new context is added to a subprocess context queue. PiperOrigin-RevId: 533297618
This commit is contained in:
@@ -18,18 +18,6 @@ go_template_instance(
|
||||
},
|
||||
)
|
||||
|
||||
go_template_instance(
|
||||
name = "subprocess_list",
|
||||
out = "subprocess_list.go",
|
||||
package = "systrap",
|
||||
prefix = "subprocess",
|
||||
template = "//pkg/ilist:generic_list",
|
||||
types = {
|
||||
"Element": "*subprocess",
|
||||
"Linker": "*subprocess",
|
||||
},
|
||||
)
|
||||
|
||||
go_template_instance(
|
||||
name = "subprocess_refs",
|
||||
out = "subprocess_refs.go",
|
||||
@@ -64,7 +52,6 @@ go_library(
|
||||
"subprocess_arm64.go",
|
||||
"subprocess_linux.go",
|
||||
"subprocess_linux_unsafe.go",
|
||||
"subprocess_list.go",
|
||||
"subprocess_pool.go",
|
||||
"subprocess_refs.go",
|
||||
"subprocess_unsafe.go",
|
||||
|
||||
@@ -210,11 +210,6 @@ type fastPathDispatcher struct {
|
||||
// fastPathDisabledTS is the time stamp when the stub fast path was
|
||||
// disabled. It is zero if the fast path is enabled.
|
||||
fastPathDisabledTS atomic.Uint64
|
||||
|
||||
subprocessListMu sync.Mutex
|
||||
// subprocessList contains subprocesses with at least one awake context.
|
||||
// +checklocks:subprocessListMu
|
||||
subprocessList subprocessList
|
||||
}
|
||||
|
||||
var dispatcher fastPathDispatcher
|
||||
@@ -256,29 +251,9 @@ func (q *fastPathDispatcher) stubFastPathEnabled() bool {
|
||||
// disableStubFastPath disables the fast path over all subprocesses with active
|
||||
// contexts.
|
||||
func (q *fastPathDispatcher) disableStubFastPath() {
|
||||
q.subprocessListMu.Lock()
|
||||
defer q.subprocessListMu.Unlock()
|
||||
|
||||
for s := q.subprocessList.Front(); s != nil; s = s.Next() {
|
||||
s.contextQueue.disableFastPath()
|
||||
}
|
||||
q.fastPathDisabledTS.Store(uint64(cputicks()))
|
||||
}
|
||||
|
||||
func (q *fastPathDispatcher) activateSubprocess(s *subprocess) {
|
||||
q.subprocessListMu.Lock()
|
||||
defer q.subprocessListMu.Unlock()
|
||||
|
||||
q.subprocessList.PushBack(s)
|
||||
}
|
||||
|
||||
func (q *fastPathDispatcher) deactivateSubprocess(s *subprocess) {
|
||||
q.subprocessListMu.Lock()
|
||||
defer q.subprocessListMu.Unlock()
|
||||
|
||||
q.subprocessList.Remove(s)
|
||||
}
|
||||
|
||||
// deep_sleep_timeout is the timeout after which we stops polling and fall asleep.
|
||||
//
|
||||
// The value is 40µs for 2GHz CPU. This timeout matches the sentry<->stub round
|
||||
|
||||
@@ -121,7 +121,6 @@ const (
|
||||
type subprocess struct {
|
||||
platform.NoAddressSpaceIO
|
||||
subprocessRefs
|
||||
subprocessEntry
|
||||
|
||||
// requests is used to signal creation of new threads.
|
||||
requests chan any
|
||||
@@ -689,14 +688,9 @@ func (s *subprocess) incAwakeContexts() {
|
||||
if nr > uint32(maxSysmsgThreads) {
|
||||
return
|
||||
}
|
||||
if nr == 1 {
|
||||
dispatcher.activateSubprocess(s)
|
||||
}
|
||||
nr = nrMaxAwakeStubThreads.Add(1)
|
||||
if nr > fastPathContextLimit {
|
||||
if dispatcher.stubFastPathEnabled() {
|
||||
dispatcher.disableStubFastPath()
|
||||
}
|
||||
dispatcher.disableStubFastPath()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,9 +699,6 @@ func (s *subprocess) decAwakeContexts() {
|
||||
if nr >= uint32(maxSysmsgThreads) {
|
||||
return
|
||||
}
|
||||
if nr == 0 {
|
||||
dispatcher.deactivateSubprocess(s)
|
||||
}
|
||||
nrMaxAwakeStubThreads.Add(^uint32(0))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user