summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorJamie Liu <jamieliu@google.com>2018-06-14 11:34:15 -0700
committerShentubot <shentubot@google.com>2018-06-14 11:35:11 -0700
commit657db692b2241d89a324acc246b3c5230d8bd6ac (patch)
treefe4ab2219dfe26081f97d35920b6db7eacd9a216 /pkg/sentry
parentd71f5ef6885b9c241018308944e4b2e4b4857029 (diff)
Ignore expiration count in kernelCPUClockListener.Notify.
PiperOrigin-RevId: 200590832 Change-Id: I35b817ecccc9414a742dee4815dfc67d0c7d0496
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/kernel/kernel.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/sentry/kernel/kernel.go b/pkg/sentry/kernel/kernel.go
index 536461bbd..a17148af1 100644
--- a/pkg/sentry/kernel/kernel.go
+++ b/pkg/sentry/kernel/kernel.go
@@ -960,7 +960,13 @@ type kernelCPUClockListener struct {
// Notify implements ktime.TimerListener.Notify.
func (l kernelCPUClockListener) Notify(exp uint64) {
- atomic.AddUint64(&l.k.cpuClock, exp)
+ // Only increment cpuClock by 1 regardless of the number of expirations.
+ // This approximately compensates for cases where thread throttling or bad
+ // Go runtime scheduling prevents the cpuClockTicker goroutine, and
+ // presumably task goroutines as well, from executing for a long period of
+ // time. It's also necessary to prevent CPU clocks from seeing large
+ // discontinuous jumps.
+ atomic.AddUint64(&l.k.cpuClock, 1)
}
// Destroy implements ktime.TimerListener.Destroy.