From 49f7ee9e926aba71f27f647413e15c5b18324477 Mon Sep 17 00:00:00 2001 From: Konstantin Bogomolov Date: Fri, 12 Jan 2024 12:33:09 -0800 Subject: [PATCH] systrap: Rename fpState to fastpath. FPState is already used in ThreadContexts. It's better to rename this global to something more descriptive. PiperOrigin-RevId: 597920631 --- pkg/sentry/platform/systrap/context_queue.go | 4 ++-- pkg/sentry/platform/systrap/metrics.go | 8 ++++---- pkg/sentry/platform/systrap/shared_context.go | 4 ++-- pkg/sentry/platform/systrap/subprocess.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/sentry/platform/systrap/context_queue.go b/pkg/sentry/platform/systrap/context_queue.go index 8b2002b74..a309cd6d6 100644 --- a/pkg/sentry/platform/systrap/context_queue.go +++ b/pkg/sentry/platform/systrap/context_queue.go @@ -100,7 +100,7 @@ func (q *contextQueue) queuedContexts() uint32 { func (q *contextQueue) add(ctx *sharedContext) { ctx.startWaitingTS = cputicks() - if fpState.stubFastPath() { + if fastpath.stubFastPath() { q.enableFastPath() } else { q.disableFastPath() @@ -119,7 +119,7 @@ func (q *contextQueue) add(ctx *sharedContext) { atomic.StoreUint64(&q.ringbuffer[next], v) if atomic.SwapUint32(&q.usedFastPath, 0) != 0 { - fpState.usedStubFastPath.Store(true) + fastpath.usedStubFastPath.Store(true) } } diff --git a/pkg/sentry/platform/systrap/metrics.go b/pkg/sentry/platform/systrap/metrics.go index f982aee13..9a2f17f89 100644 --- a/pkg/sentry/platform/systrap/metrics.go +++ b/pkg/sentry/platform/systrap/metrics.go @@ -241,7 +241,7 @@ type fastPathState struct { } var ( - fpState = fastPathState{ + fastpath = fastPathState{ stubFPBackoff: fastPathBackoffMin, sentryFPBackoff: fastPathBackoffMin, curState: sentryOffStubOff, @@ -262,10 +262,10 @@ func controlFastPath() { for { time.Sleep(recordingPeriod) - fpState.curState(&fpState) + fastpath.curState(&fastpath) // Reset FP trackers. - fpState.usedStubFastPath.Store(false) - fpState.usedSentryFastPath.Store(false) + fastpath.usedStubFastPath.Store(false) + fastpath.usedSentryFastPath.Store(false) } } diff --git a/pkg/sentry/platform/systrap/shared_context.go b/pkg/sentry/platform/systrap/shared_context.go index 0c37ceb04..148f4c367 100644 --- a/pkg/sentry/platform/systrap/shared_context.go +++ b/pkg/sentry/platform/systrap/shared_context.go @@ -317,7 +317,7 @@ func (q *fastPathDispatcher) loop(target *sharedContext) { break } - slowPath = !fpState.sentryFastPath() || slowPath + slowPath = !fastpath.sentryFastPath() || slowPath processed = 0 now := cputicks() for ctx = q.list.Front(); ctx != nil; ctx = next { @@ -349,7 +349,7 @@ func (q *fastPathDispatcher) loop(target *sharedContext) { startedSpinning = now firstTimeout = false } else { - fpState.usedSentryFastPath.Store(true) + fastpath.usedSentryFastPath.Store(true) } // If dispatcher has been spinning for too long, send this // dispatcher to sleep. diff --git a/pkg/sentry/platform/systrap/subprocess.go b/pkg/sentry/platform/systrap/subprocess.go index f8e667608..7c3b8f2cd 100644 --- a/pkg/sentry/platform/systrap/subprocess.go +++ b/pkg/sentry/platform/systrap/subprocess.go @@ -701,7 +701,7 @@ func (s *subprocess) incAwakeContexts() { if nr > uint32(maxSysmsgThreads) { return } - fpState.nrMaxAwakeStubThreads.Add(1) + fastpath.nrMaxAwakeStubThreads.Add(1) } func (s *subprocess) decAwakeContexts() { @@ -709,7 +709,7 @@ func (s *subprocess) decAwakeContexts() { if nr >= uint32(maxSysmsgThreads) { return } - fpState.nrMaxAwakeStubThreads.Add(^uint32(0)) + fastpath.nrMaxAwakeStubThreads.Add(^uint32(0)) } // switchToApp is called from the main SwitchToApp entrypoint.