Skip to content

Commit d5b1802

Browse files
committed
Introduce CPUAffinity process property instead of execCPUAffinity
This change introduces more generic `CPUAffinity` property of `Process` to specify desired CPU affinities while performing operations on create, start and exec operations. Signed-off-by: Alexander Kanevskiy <[email protected]>
1 parent e3c8d12 commit d5b1802

File tree

3 files changed

+67
-7
lines changed

3 files changed

+67
-7
lines changed

config.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,18 +340,38 @@ For Linux-based systems, the `process` object supports the following process-spe
340340

341341
* **`class`** (string, REQUIRED) specifies the I/O scheduling class. Possible values are `IOPRIO_CLASS_RT`, `IOPRIO_CLASS_BE`, and `IOPRIO_CLASS_IDLE`.
342342
* **`priority`** (int, REQUIRED) specifies the priority level within the class. The value should be an integer ranging from 0 (highest) to 7 (lowest).
343-
* **`execCPUAffinity`** (object, OPTIONAL) specifies CPU affinity used to execute the process.
343+
* **`CPUAffinity`** (object, OPTIONAL) specifies CPU affinity used to execute processes in the runtime and the container.
344+
All the properties in this setting expects as argument a string that contain a comma-separated list, with dashes to represent
345+
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,
346+
the runtime SHOULD NOT change process' CPU affinity, and the affinity is determined by the Linux kernel.
347+
The following properties are available:
348+
* **`runtimeCreate`** (string, OPTIONAL) is a list of CPUs the runtime parent process should run on during the runtime creation stage,
349+
before entering the container's namespaces or cgroups. CPU affinity should be applied on early stages of container creation,
350+
so that any potential CPU consuming operations inside runtime (e.g. [`createRuntime` hooks](#createRuntime-hooks))
351+
will be affinitized to specified list of CPUs.
352+
* **`containerCreate`** (string, OPTIONAL) is a list of CPUs the process should run on during the container creation stage,
353+
after entering the container's namespaces but before the user process or any of [`createContainer` hooks](#createContainer-hooks) are executed.
354+
* **`containerStart`** (string, OPTIONAL) is a list of CPUs the process should be shoud run on during the container start stage,
355+
inside the container's namespace during `start` operation. The affinity should be applied before executing [`startContainer` hooks](#startContainer-hooks).
356+
* **`runtimeExec`** (string, OPTIONAL) is a list of CPUs a runtime parent
357+
process to be run during `exec` operation, before the transition to container's
358+
cgroup.
359+
* **`containerExec`** (string, OPTIONAL) is a list of CPUs the process will be run on during `exec` operationon
360+
after the transition to container's cgroup.
361+
* **`execCPUAffinity`** (object, OPTIONAL, **DEPRECATED**) specifies CPU affinity used to execute the process.
344362
This setting is not applicable to the container's init process.
345363
The following properties are available:
346364
* **`initial`** (string, OPTIONAL) is a list of CPUs a runtime parent
347365
process to be run on initially, before the transition to container's
348366
cgroup. This is a a comma-separated list, with dashes to represent
349367
ranges. For example, `0-3,7` represents CPUs 0,1,2,3, and 7.
368+
Deprecated in favor of `runtimeExec` in `CPUAffinity`.
350369
* **`final`** (string, OPTIONAL) is a list of CPUs the process will be run
351370
on after the transition to container's cgroup. The format is the same as
352371
for `initial`. If omitted or empty, runtime SHOULD NOT change process'
353372
CPU affinity after the process is moved to container's cgroup, and the
354373
final affinity is determined by the Linux kernel.
374+
Deprecated in favor of `containerExec` in `CPUAffinity`.
355375

356376
### <a name="configZOSProcess" />z/OS Process
357377

@@ -435,9 +455,11 @@ _Note: symbolic name for uid and gid, such as uname and gname respectively, are
435455
"soft": 1024
436456
}
437457
],
438-
"execCPUAffinity": {
439-
"initial": "7",
440-
"final": "0-3,7"
458+
"CPUAffinity": {
459+
"runtimeCreate": "7",
460+
"runtimeExec": "7",
461+
"containerCreate": "0-3,7",
462+
"containerExec": "0-3,7"
441463
}
442464
}
443465
```

schema/config-schema.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,31 @@
221221
}
222222
}
223223
},
224+
"CPUAffinity": {
225+
"type": "object",
226+
"properties": {
227+
"runtimeCreate": {
228+
"type": "string",
229+
"pattern": "^[0-9, -]*$"
230+
},
231+
"containerCreate": {
232+
"type": "string",
233+
"pattern": "^[0-9, -]*$"
234+
},
235+
"containerStart": {
236+
"type": "string",
237+
"pattern": "^[0-9, -]*$"
238+
},
239+
"runtimeExec": {
240+
"type": "string",
241+
"pattern": "^[0-9, -]*$"
242+
},
243+
"containerExec": {
244+
"type": "string",
245+
"pattern": "^[0-9, -]*$"
246+
}
247+
}
248+
},
224249
"execCPUAffinity": {
225250
"type": "object",
226251
"properties": {

specs-go/config.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ type Process struct {
9494
SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"`
9595
// IOPriority contains the I/O priority settings for the cgroup.
9696
IOPriority *LinuxIOPriority `json:"ioPriority,omitempty" platform:"linux"`
97+
// ExecCPUAffinity is Deprecated.
9798
// ExecCPUAffinity specifies CPU affinity for exec processes.
98-
ExecCPUAffinity *CPUAffinity `json:"execCPUAffinity,omitempty" platform:"linux"`
99+
// Deprecated: use [Process.CPUAffinity]
100+
ExecCPUAffinity *ExecCPUAffinity `json:"execCPUAffinity,omitempty" platform:"linux"`
101+
// CPUAffinity specifies CPU affinity for executing processes
102+
CPUAffinity *CPUAffinity `json:"CPUAffinity,omitempty" platform:"linux"`
99103
}
100104

101105
// LinuxCapabilities specifies the list of allowed capabilities that are kept for a process.
@@ -129,12 +133,21 @@ const (
129133
IOPRIO_CLASS_IDLE IOPriorityClass = "IOPRIO_CLASS_IDLE"
130134
)
131135

132-
// CPUAffinity specifies process' CPU affinity.
133-
type CPUAffinity struct {
136+
// ExecCPUAffinity specifies process' CPU affinity during runtime exec operation.
137+
type ExecCPUAffinity struct {
134138
Initial string `json:"initial,omitempty"`
135139
Final string `json:"final,omitempty"`
136140
}
137141

142+
// CPUAffinity specifies process' CPU affinity.
143+
type CPUAffinity struct {
144+
RuntimeCreate string `json:"runtimeCreate,omitempty"`
145+
ContainerCreate string `json:"containerCreate,omitempty"`
146+
ContainerStart string `json:"containerStart,omitempty"`
147+
RuntimeExec string `json:"runtimeExec,omitempty"`
148+
ContainerExec string `json:"containerExec,omitempty"`
149+
}
150+
138151
// Box specifies dimensions of a rectangle. Used for specifying the size of a console.
139152
type Box struct {
140153
// Height is the vertical dimension of a box.

0 commit comments

Comments
 (0)