From 09c91eb6ddf9b9d3282fac6e3971988de289ddc4 Mon Sep 17 00:00:00 2001 From: Charlie Doern Date: Thu, 30 Jun 2022 15:16:41 -0400 Subject: [PATCH] additional cgroup testing and implementation of cpu-shares (weight in systemd) Signed-off-by: Charlie Doern --- pkg/cgroups/cgroups_linux_test.go | 3 +++ pkg/cgroups/systemd_linux.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/pkg/cgroups/cgroups_linux_test.go b/pkg/cgroups/cgroups_linux_test.go index b218b7007..0c19266f6 100644 --- a/pkg/cgroups/cgroups_linux_test.go +++ b/pkg/cgroups/cgroups_linux_test.go @@ -45,6 +45,9 @@ func TestResources(t *testing.T) { var resources configs.Resources resources.CpuPeriod = 100000 resources.CpuQuota = 100000 + resources.CpuShares = 100 + resources.CpusetCpus = "0" + resources.CpusetMems = "0" resources.Memory = 900 resources.MemorySwap = 1000 resources.BlkioWeight = 300 diff --git a/pkg/cgroups/systemd_linux.go b/pkg/cgroups/systemd_linux.go index ee9f584de..97128a954 100644 --- a/pkg/cgroups/systemd_linux.go +++ b/pkg/cgroups/systemd_linux.go @@ -140,6 +140,10 @@ func resourcesToProps(res *configs.Resources) (map[string]uint64, map[string]str uMap["CPUQuotaPerSecUSec"] = cpuQuotaPerSecUSec } + if res.CpuShares != 0 { + uMap["CPUWeight"] = res.CpuShares + } + // CPUSet if res.CpusetCpus != "" { bits := []byte(res.CpusetCpus)