summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorZhaozhong Ni <nzz@google.com>2018-09-27 10:41:28 -0700
committerShentubot <shentubot@google.com>2018-09-27 12:52:25 -0700
commit234f36b6f2cb0db74d119079e5244619d6ea38ad (patch)
tree5047824f7ab217f1eb887dbdf27c2f389a9ab482 /pkg
parentb514ab05897bca53c1d4f71c912f2977b3134daf (diff)
sentry: export cpuTime function.
PiperOrigin-RevId: 214798278 Change-Id: Id59d1ceb35037cda0689d3a1c4844e96c6957615
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/state/state_metadata.go2
-rw-r--r--pkg/sentry/state/state_unsafe.go3
2 files changed, 3 insertions, 2 deletions
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 {