Skip to content

Commit aa1234e

Browse files
committed
linux: clarify pids cgroup settings
While the original wording did not provide any justification for this, some runtimes have incorrectly treated a pids.limit value of 0 as being equivalent to "max" or otherwise handle it suboptimally. So, add some clarifying wording that the correct representation of max is -1 (like every other cgroup configuration) and that users should not treat 0 as a special value of any kind. Note that a pids.limit value of 0 is actually different to 1 now that CLONE_INTO_CGROUP exists (at the time pids was added to the kernel and the spec, this feature didn't exist and so it may have seemed redundant to have two equivalent values). For the Go API, this is effectively a partial revert of commit ef9ce84 ("specs-go/config: fix required items type") which turned the limit value into a bare int64. Fixes: ef9ce84 ("specs-go/config: fix required items type") Fixes: 2ce2c86 ("runtime: config: linux: add cgroups information") Signed-off-by: Aleksa Sarai <[email protected]>
1 parent e3c8d12 commit aa1234e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

config-linux.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,9 @@ For more information, see the kernel cgroups documentation about [pids][cgroup-v
666666

667667
The following parameters can be specified to set up the controller:
668668

669-
* **`limit`** *(int64, REQUIRED)* - specifies the maximum number of tasks in the cgroup
669+
* **`limit`** *(int64, OPTIONAL)* - specifies the maximum number of tasks in the cgroup, with `-1` indicating no limit (`max`).
670+
671+
> Note: Even though it may superficially seem redundant, `0` is a valid limit value for the `pids` cgroup controller from the kernel's perspective and SHOULD be treated as such by runtimes.
670672
671673
#### Example
672674

specs-go/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ type LinuxCPU struct {
434434
// LinuxPids for Linux cgroup 'pids' resource management (Linux 4.3)
435435
type LinuxPids struct {
436436
// Maximum number of PIDs. Default is "no limit".
437-
Limit int64 `json:"limit"`
437+
Limit *int64 `json:"limit,omitempty"`
438438
}
439439

440440
// LinuxNetwork identification and priority configuration

0 commit comments

Comments
 (0)