diff --git a/config.md b/config.md index d642359d1..d31c4e4a5 100644 --- a/config.md +++ b/config.md @@ -340,18 +340,38 @@ For Linux-based systems, the `process` object supports the following process-spe * **`class`** (string, REQUIRED) specifies the I/O scheduling class. Possible values are `IOPRIO_CLASS_RT`, `IOPRIO_CLASS_BE`, and `IOPRIO_CLASS_IDLE`. * **`priority`** (int, REQUIRED) specifies the priority level within the class. The value should be an integer ranging from 0 (highest) to 7 (lowest). -* **`execCPUAffinity`** (object, OPTIONAL) specifies CPU affinity used to execute the process. +* **`CPUAffinity`** (object, OPTIONAL) specifies CPU affinity used to execute processes in the runtime and the container. + All the properties in this setting expects as argument a string that contain a comma-separated list, with dashes to represent + ranges. For example, `0-3,7` represents CPUs 0,1,2,3, and 7. If omitted or empty for particular [lifecycle](runtime.md#lifecycle) stage, + the runtime SHOULD NOT change process' CPU affinity, and the affinity is determined by the Linux kernel. + The following properties are available: + * **`runtimeCreate`** (string, OPTIONAL) is a list of CPUs the runtime parent process should run on during the runtime creation stage, + before entering the container's namespaces or cgroups. CPU affinity should be applied on early stages of container creation, + so that any potential CPU consuming operations inside runtime (e.g. [`createRuntime` hooks](#createRuntime-hooks)) + will be affinitized to specified list of CPUs. + * **`containerCreate`** (string, OPTIONAL) is a list of CPUs the process should run on during the container creation stage, + after entering the container's namespaces but before the user process or any of [`createContainer` hooks](#createContainer-hooks) are executed. + * **`containerStart`** (string, OPTIONAL) is a list of CPUs the process should be shoud run on during the container start stage, + inside the container's namespace during `start` operation. The affinity should be applied before executing [`startContainer` hooks](#startContainer-hooks). + * **`runtimeExec`** (string, OPTIONAL) is a list of CPUs a runtime parent + process to be run during `exec` operation, before the transition to container's + cgroup. + * **`containerExec`** (string, OPTIONAL) is a list of CPUs the process will be run on during `exec` operationon + after the transition to container's cgroup. +* **`execCPUAffinity`** (object, OPTIONAL, **DEPRECATED**) specifies CPU affinity used to execute the process. This setting is not applicable to the container's init process. The following properties are available: * **`initial`** (string, OPTIONAL) is a list of CPUs a runtime parent process to be run on initially, before the transition to container's cgroup. This is a a comma-separated list, with dashes to represent ranges. For example, `0-3,7` represents CPUs 0,1,2,3, and 7. + Deprecated in favor of `runtimeExec` in `CPUAffinity`. * **`final`** (string, OPTIONAL) is a list of CPUs the process will be run on after the transition to container's cgroup. The format is the same as for `initial`. If omitted or empty, runtime SHOULD NOT change process' CPU affinity after the process is moved to container's cgroup, and the final affinity is determined by the Linux kernel. + Deprecated in favor of `containerExec` in `CPUAffinity`. ### z/OS Process @@ -435,9 +455,11 @@ _Note: symbolic name for uid and gid, such as uname and gname respectively, are "soft": 1024 } ], - "execCPUAffinity": { - "initial": "7", - "final": "0-3,7" + "CPUAffinity": { + "runtimeCreate": "7", + "runtimeExec": "7", + "containerCreate": "0-3,7", + "containerExec": "0-3,7" } } ``` diff --git a/schema/config-schema.json b/schema/config-schema.json index 5124def5f..7dc3e016b 100644 --- a/schema/config-schema.json +++ b/schema/config-schema.json @@ -221,6 +221,31 @@ } } }, + "CPUAffinity": { + "type": "object", + "properties": { + "runtimeCreate": { + "type": "string", + "pattern": "^[0-9, -]*$" + }, + "containerCreate": { + "type": "string", + "pattern": "^[0-9, -]*$" + }, + "containerStart": { + "type": "string", + "pattern": "^[0-9, -]*$" + }, + "runtimeExec": { + "type": "string", + "pattern": "^[0-9, -]*$" + }, + "containerExec": { + "type": "string", + "pattern": "^[0-9, -]*$" + } + } + }, "execCPUAffinity": { "type": "object", "properties": { diff --git a/specs-go/config.go b/specs-go/config.go index 36d28032e..69e5a12fd 100644 --- a/specs-go/config.go +++ b/specs-go/config.go @@ -94,8 +94,12 @@ type Process struct { SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"` // IOPriority contains the I/O priority settings for the cgroup. IOPriority *LinuxIOPriority `json:"ioPriority,omitempty" platform:"linux"` + // ExecCPUAffinity is Deprecated. // ExecCPUAffinity specifies CPU affinity for exec processes. - ExecCPUAffinity *CPUAffinity `json:"execCPUAffinity,omitempty" platform:"linux"` + // Deprecated: use [Process.CPUAffinity] + ExecCPUAffinity *ExecCPUAffinity `json:"execCPUAffinity,omitempty" platform:"linux"` + // CPUAffinity specifies CPU affinity for executing processes + CPUAffinity *CPUAffinity `json:"CPUAffinity,omitempty" platform:"linux"` } // LinuxCapabilities specifies the list of allowed capabilities that are kept for a process. @@ -129,12 +133,21 @@ const ( IOPRIO_CLASS_IDLE IOPriorityClass = "IOPRIO_CLASS_IDLE" ) -// CPUAffinity specifies process' CPU affinity. -type CPUAffinity struct { +// ExecCPUAffinity specifies process' CPU affinity during runtime exec operation. +type ExecCPUAffinity struct { Initial string `json:"initial,omitempty"` Final string `json:"final,omitempty"` } +// CPUAffinity specifies process' CPU affinity. +type CPUAffinity struct { + RuntimeCreate string `json:"runtimeCreate,omitempty"` + ContainerCreate string `json:"containerCreate,omitempty"` + ContainerStart string `json:"containerStart,omitempty"` + RuntimeExec string `json:"runtimeExec,omitempty"` + ContainerExec string `json:"containerExec,omitempty"` +} + // Box specifies dimensions of a rectangle. Used for specifying the size of a console. type Box struct { // Height is the vertical dimension of a box.