k3s/vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs2/cpuset.go

31 lines
620 B
Go
Raw Normal View History

// +build linux
package fs2
import (
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/configs"
)
func isCpusetSet(r *configs.Resources) bool {
return r.CpusetCpus != "" || r.CpusetMems != ""
2020-08-10 17:43:49 +00:00
}
func setCpuset(dirPath string, r *configs.Resources) error {
if !isCpusetSet(r) {
2020-08-10 17:43:49 +00:00
return nil
}
if r.CpusetCpus != "" {
if err := cgroups.WriteFile(dirPath, "cpuset.cpus", r.CpusetCpus); err != nil {
return err
}
}
if r.CpusetMems != "" {
if err := cgroups.WriteFile(dirPath, "cpuset.mems", r.CpusetMems); err != nil {
return err
}
}
return nil
}