diff options
author | Rahat Mahmood <rahat@google.com> | 2021-04-05 16:00:17 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-04-05 16:06:11 -0700 |
commit | 88f198c2a9da1bac9726db18af4e7615aaa65476 (patch) | |
tree | b3be2c4c001ff6899197c6e380178bf4c1dd9726 /pkg/sentry/fsimpl/cgroupfs/cpu.go | |
parent | 2d9095c7a669ad2632f12de8d0918f8bf48b499e (diff) |
Allow default control values to be set for cgroupfs.
PiperOrigin-RevId: 366891806
Diffstat (limited to 'pkg/sentry/fsimpl/cgroupfs/cpu.go')
-rw-r--r-- | pkg/sentry/fsimpl/cgroupfs/cpu.go | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/pkg/sentry/fsimpl/cgroupfs/cpu.go b/pkg/sentry/fsimpl/cgroupfs/cpu.go index 4641d613c..24d86a277 100644 --- a/pkg/sentry/fsimpl/cgroupfs/cpu.go +++ b/pkg/sentry/fsimpl/cgroupfs/cpu.go @@ -28,22 +28,36 @@ type cpuController struct { controllerCommon // CFS bandwidth control parameters, values in microseconds. - cfsPeriod uint64 + cfsPeriod int64 cfsQuota int64 // CPU shares, values should be (num core * 1024). - shares uint64 + shares int64 } var _ controller = (*cpuController)(nil) -func newCPUController(fs *filesystem) *cpuController { +func newCPUController(fs *filesystem, defaults map[string]int64) *cpuController { // Default values for controller parameters from Linux. c := &cpuController{ cfsPeriod: 100000, cfsQuota: -1, shares: 1024, } + + if val, ok := defaults["cpu.cfs_period_us"]; ok { + c.cfsPeriod = val + delete(defaults, "cpu.cfs_period_us") + } + if val, ok := defaults["cpu.cfs_quota_us"]; ok { + c.cfsQuota = val + delete(defaults, "cpu.cfs_quota_us") + } + if val, ok := defaults["cpu.shares"]; ok { + c.shares = val + delete(defaults, "cpu.shares") + } + c.controllerCommon.init(controllerCPU, fs) return c } |