Skip to content

Commit b8ca7de

Browse files
committed
Deprecate KernelMemory
Kernel memory limit is not supported on cgroup v2. Even on cgroup v1, kernel memory limit (`kmem.limit_in_bytes`) has been deprecated since kernel 5.4. torvalds/linux@0158115 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
1 parent a770dc1 commit b8ca7de

File tree

6 files changed

+24
-7
lines changed

6 files changed

+24
-7
lines changed

api/swagger.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,13 @@ definitions:
528528
items:
529529
$ref: "#/definitions/DeviceRequest"
530530
KernelMemory:
531-
description: "Kernel memory limit in bytes."
531+
description: |
532+
Kernel memory limit in bytes.
533+
534+
<p><br /></p>
535+
536+
> **Deprecated**: This field is deprecated as the kernel 5.4 deprecated
537+
> `kmem.limit_in_bytes`.
532538
type: "integer"
533539
format: "int64"
534540
example: 209715200
@@ -4321,7 +4327,13 @@ definitions:
43214327
type: "boolean"
43224328
example: true
43234329
KernelMemory:
4324-
description: "Indicates if the host has kernel memory limit support enabled."
4330+
description: |
4331+
Indicates if the host has kernel memory limit support enabled.
4332+
4333+
<p><br /></p>
4334+
4335+
> **Deprecated**: This field is deprecated as the kernel 5.4 deprecated
4336+
> `kmem.limit_in_bytes`.
43254337
type: "boolean"
43264338
example: true
43274339
CpuCfsPeriod:

api/types/container/host_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ type Resources struct {
361361
Devices []DeviceMapping // List of devices to map inside the container
362362
DeviceCgroupRules []string // List of rule to be added to the device cgroup
363363
DeviceRequests []DeviceRequest // List of device requests for device drivers
364-
KernelMemory int64 // Kernel memory limit (in bytes)
364+
KernelMemory int64 // Kernel memory limit (in bytes), Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes
365365
KernelMemoryTCP int64 // Hard limit for kernel TCP buffer memory (in bytes)
366366
MemoryReservation int64 // Memory soft limit (in bytes)
367367
MemorySwap int64 // Total memory usage (memory + swap); set `-1` to enable unlimited swap

api/types/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ type Info struct {
158158
Plugins PluginsInfo
159159
MemoryLimit bool
160160
SwapLimit bool
161-
KernelMemory bool
161+
KernelMemory bool // Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes
162162
KernelMemoryTCP bool
163163
CPUCfsPeriod bool `json:"CpuCfsPeriod"`
164164
CPUCfsQuota bool `json:"CpuCfsQuota"`

daemon/daemon_unix.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,12 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, sysIn
465465
if resources.Memory > 0 && resources.MemoryReservation > 0 && resources.Memory < resources.MemoryReservation {
466466
return warnings, fmt.Errorf("Minimum memory limit can not be less than memory reservation limit, see usage")
467467
}
468+
if resources.KernelMemory > 0 {
469+
// Kernel memory limit is not supported on cgroup v2.
470+
// Even on cgroup v1, kernel memory limit (`kmem.limit_in_bytes`) has been deprecated since kernel 5.4.
471+
// https://github.com/torvalds/linux/commit/0158115f702b0ba208ab0b5adf44cae99b3ebcc7
472+
warnings = append(warnings, "Specifying a kernel memory limit is deprecated and will be removed in a future release.")
473+
}
468474
if resources.KernelMemory > 0 && !sysInfo.KernelMemory {
469475
warnings = append(warnings, "Your kernel does not support kernel memory limit capabilities or the cgroup is not mounted. Limitation discarded.")
470476
resources.KernelMemory = 0

daemon/info_unix.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo)
100100
if !v.SwapLimit {
101101
v.Warnings = append(v.Warnings, "WARNING: No swap limit support")
102102
}
103-
if !v.KernelMemory {
104-
v.Warnings = append(v.Warnings, "WARNING: No kernel memory limit support")
105-
}
106103
if !v.KernelMemoryTCP {
107104
v.Warnings = append(v.Warnings, "WARNING: No kernel memory TCP limit support")
108105
}

docs/api/version-history.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ keywords: "API, Docker, rcli, REST, documentation"
7474
job-mode service.
7575
* `GET /containers/{id}/stats` now accepts a query param (`one-shot`) which, when used with `stream=false` fetches a
7676
single set of stats instead of waiting for two collection cycles to have 2 CPU stats over a 1 second period.
77+
* The `KernelMemory` field in `HostConfig.Resources` is now deprecated.
78+
* The `KernelMemory` field in `Info` is now deprecated.
7779

7880
## v1.40 API changes
7981

0 commit comments

Comments
 (0)