From 234f36b6f2cb0db74d119079e5244619d6ea38ad Mon Sep 17 00:00:00 2001 From: Zhaozhong Ni Date: Thu, 27 Sep 2018 10:41:28 -0700 Subject: sentry: export cpuTime function. PiperOrigin-RevId: 214798278 Change-Id: Id59d1ceb35037cda0689d3a1c4844e96c6957615 --- pkg/sentry/state/state_metadata.go | 2 +- pkg/sentry/state/state_unsafe.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'pkg/sentry') diff --git a/pkg/sentry/state/state_metadata.go b/pkg/sentry/state/state_metadata.go index b6d3dbcb4..afa21672a 100644 --- a/pkg/sentry/state/state_metadata.go +++ b/pkg/sentry/state/state_metadata.go @@ -28,7 +28,7 @@ const ( ) func addSaveMetadata(m map[string]string) { - t, err := cpuTime() + t, err := CPUTime() if err != nil { log.Warningf("Error getting cpu time: %v", err) } diff --git a/pkg/sentry/state/state_unsafe.go b/pkg/sentry/state/state_unsafe.go index 53814ef70..3ff7d24c8 100644 --- a/pkg/sentry/state/state_unsafe.go +++ b/pkg/sentry/state/state_unsafe.go @@ -23,7 +23,8 @@ import ( "gvisor.googlesource.com/gvisor/pkg/abi/linux" ) -func cpuTime() (time.Duration, error) { +// CPUTime returns the CPU time usage by Sentry and app. +func CPUTime() (time.Duration, error) { var ts syscall.Timespec _, _, errno := syscall.RawSyscall(syscall.SYS_CLOCK_GETTIME, uintptr(linux.CLOCK_PROCESS_CPUTIME_ID), uintptr(unsafe.Pointer(&ts)), 0) if errno != 0 { -- cgit v1.2.3