From 7571d3d9f20c4e42b7db38929be5de861c83a6eb Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 5 Jun 2020 10:36:58 +0200 Subject: [PATCH] cgroup: add cgroup v2 support allow users to specify cgroup v2 resources. Each element in the map refers to a file in the cgroup v2 hierarchy and the element value has its content. Signed-off-by: Giuseppe Scrivano --- config-linux.md | 25 +++++++++++++++++++++++++ schema/config-linux.json | 3 +++ specs-go/config.go | 2 ++ 3 files changed, 30 insertions(+) diff --git a/config-linux.md b/config-linux.md index 6f710daf8..848fc5c20 100644 --- a/config-linux.md +++ b/config-linux.md @@ -494,6 +494,31 @@ You MUST specify at least one of the `hcaHandles` or `hcaObjects` in a given ent } ``` +## Unified + +**`unified`** (object, OPTIONAL) allows cgroup v2 parameters to be to be set and modified for the container. + +Each key in the map refers to a file in the cgroup unified hierarchy. + +The OCI runtime MUST ensure that the needed cgroup controllers are enabled for the cgroup. + +Configuration unknown to the runtime MUST still be written to the relevant file. + +The runtime MUST generate an error when the configuration refers to a cgroup controller that is not present or that cannot be enabled. + +### Example + +```json +"unified": { + "io.max": "259:0 rbps=2097152 wiops=120\n253:0 rbps=2097152 wiops=120", + "hugetlb.1GB.max": "1073741824" +} +``` + +If a controller is enabled on the cgroup v2 hierarchy but the configuration is provided for the cgroup v1 equivalent controller, the runtime MAY attempt a conversion. + +If the conversion is not possible the runtime MUST generate an error. + ## IntelRdt **`intelRdt`** (object, OPTIONAL) represents the [Intel Resource Director Technology][intel-rdt-cat-kernel-interface]. diff --git a/schema/config-linux.json b/schema/config-linux.json index 98295c4cf..83478cc9f 100644 --- a/schema/config-linux.json +++ b/schema/config-linux.json @@ -34,6 +34,9 @@ "resources": { "type": "object", "properties": { + "unified": { + "$ref": "defs.json#/definitions/mapStringString" + }, "devices": { "type": "array", "items": { diff --git a/specs-go/config.go b/specs-go/config.go index 08af67798..d44b409a5 100644 --- a/specs-go/config.go +++ b/specs-go/config.go @@ -372,6 +372,8 @@ type LinuxResources struct { // Limits are a set of key value pairs that define RDMA resource limits, // where the key is device name and value is resource limits. Rdma map[string]LinuxRdma `json:"rdma,omitempty"` + // Unified resources. + Unified map[string]string `json:"unified,omitempty"` } // LinuxDevice represents the mknod information for a Linux special device file