From 0a6eaed50b83a35a687699aa5e871b80605c9f46 Mon Sep 17 00:00:00 2001 From: Nayana Bidari Date: Thu, 22 Apr 2021 16:04:40 -0700 Subject: Add weirdness sentry metric. Weirdness metric contains fields to track the number of clock fallback, partial result and vsyscalls. This metric will avoid the overhead of having three different metrics (fallbackMetric, partialResultMetric, vsyscallCount). PiperOrigin-RevId: 369970218 --- pkg/sentry/fsimpl/testutil/BUILD | 1 + pkg/sentry/fsimpl/testutil/kernel.go | 3 +++ pkg/sentry/kernel/task_syscall.go | 1 + pkg/sentry/syscalls/linux/error.go | 1 + pkg/sentry/time/calibrated_clock.go | 1 + 5 files changed, 7 insertions(+) (limited to 'pkg/sentry') diff --git a/pkg/sentry/fsimpl/testutil/BUILD b/pkg/sentry/fsimpl/testutil/BUILD index b3f9d1010..c766164c7 100644 --- a/pkg/sentry/fsimpl/testutil/BUILD +++ b/pkg/sentry/fsimpl/testutil/BUILD @@ -17,6 +17,7 @@ go_library( "//pkg/fspath", "//pkg/hostarch", "//pkg/memutil", + "//pkg/metric", "//pkg/sentry/fsbridge", "//pkg/sentry/fsimpl/tmpfs", "//pkg/sentry/kernel", diff --git a/pkg/sentry/fsimpl/testutil/kernel.go b/pkg/sentry/fsimpl/testutil/kernel.go index 807e4f44a..33e52ce64 100644 --- a/pkg/sentry/fsimpl/testutil/kernel.go +++ b/pkg/sentry/fsimpl/testutil/kernel.go @@ -25,6 +25,7 @@ import ( "gvisor.dev/gvisor/pkg/cpuid" "gvisor.dev/gvisor/pkg/fspath" "gvisor.dev/gvisor/pkg/memutil" + "gvisor.dev/gvisor/pkg/metric" "gvisor.dev/gvisor/pkg/sentry/fsbridge" "gvisor.dev/gvisor/pkg/sentry/fsimpl/tmpfs" "gvisor.dev/gvisor/pkg/sentry/kernel" @@ -62,6 +63,8 @@ func Boot() (*kernel.Kernel, error) { return nil, fmt.Errorf("creating platform: %v", err) } + metric.CreateSentryMetrics() + kernel.VFS2Enabled = true k := &kernel.Kernel{ Platform: plat, diff --git a/pkg/sentry/kernel/task_syscall.go b/pkg/sentry/kernel/task_syscall.go index 2c658d001..36855e3ec 100644 --- a/pkg/sentry/kernel/task_syscall.go +++ b/pkg/sentry/kernel/task_syscall.go @@ -285,6 +285,7 @@ func (*runSyscallExit) execute(t *Task) taskRunState { // task's next run state. func (t *Task) doVsyscall(addr hostarch.Addr, sysno uintptr) taskRunState { vsyscallCount.Increment() + metric.WeirdnessMetric.Increment("vsyscall_count") // Grab the caller up front, to make sure there's a sensible stack. caller := t.Arch().Native(uintptr(0)) diff --git a/pkg/sentry/syscalls/linux/error.go b/pkg/sentry/syscalls/linux/error.go index 37121186a..c668e81ac 100644 --- a/pkg/sentry/syscalls/linux/error.go +++ b/pkg/sentry/syscalls/linux/error.go @@ -39,6 +39,7 @@ var ( // takes a variadic number of arguments. func incrementPartialResultMetric() { partialResultMetric.Increment() + metric.WeirdnessMetric.Increment("partial_result") } // HandleIOErrorVFS2 handles special error cases for partial results. For some diff --git a/pkg/sentry/time/calibrated_clock.go b/pkg/sentry/time/calibrated_clock.go index f9a93115d..94f98d746 100644 --- a/pkg/sentry/time/calibrated_clock.go +++ b/pkg/sentry/time/calibrated_clock.go @@ -103,6 +103,7 @@ func (c *CalibratedClock) resetLocked(str string, v ...interface{}) { c.ready = false c.ref.Reset() fallbackMetric.Increment() + metric.WeirdnessMetric.Increment("fallback") } // updateParams updates the timekeeping parameters based on the passed -- cgit v1.2.3