Skip to content

Commit 198f23f

Browse files
authored
Merge pull request #876 from justincormack/memory-int64
Make Linux memory allocations int64 not uint64
2 parents c1a9848 + e73cd70 commit 198f23f

File tree

5 files changed

+25
-22
lines changed

5 files changed

+25
-22
lines changed

config-linux.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,16 @@ For more information, see the kernel cgroups documentation about [memory][cgroup
270270
**`memory`** (object, OPTIONAL) represents the cgroup subsystem `memory` and it's used to set limits on the container's memory usage.
271271
For more information, see the kernel cgroups documentation about [memory][cgroup-v1-memory].
272272

273-
The following parameters can be specified to set up the controller:
273+
Values for memory specify the limit in bytes, or `-1` for unlimited memory.
274+
275+
* **`limit`** *(int64, OPTIONAL)* - sets limit of memory usage
276+
* **`reservation`** *(int64, OPTIONAL)* - sets soft limit of memory usage
277+
* **`swap`** *(int64, OPTIONAL)* - sets limit of memory+Swap usage
278+
* **`kernel`** *(int64, OPTIONAL)* - sets hard limit for kernel memory
279+
* **`kernelTCP`** *(int64, OPTIONAL)* - sets hard limit for kernel TCP buffer memory
280+
281+
For `swappiness` the values are from 0 to 100. Higher means more swappy.
274282

275-
* **`limit`** *(uint64, OPTIONAL)* - sets limit of memory usage in bytes
276-
* **`reservation`** *(uint64, OPTIONAL)* - sets soft limit of memory usage in bytes
277-
* **`swap`** *(uint64, OPTIONAL)* - sets limit of memory+Swap usage
278-
* **`kernel`** *(uint64, OPTIONAL)* - sets hard limit for kernel memory
279-
* **`kernelTCP`** *(uint64, OPTIONAL)* - sets hard limit in bytes for kernel TCP buffer memory
280283
* **`swappiness`** *(uint64, OPTIONAL)* - sets swappiness parameter of vmscan (See sysctl's vm.swappiness)
281284

282285
#### Example
@@ -286,8 +289,8 @@ The following parameters can be specified to set up the controller:
286289
"limit": 536870912,
287290
"reservation": 536870912,
288291
"swap": 536870912,
289-
"kernel": 0,
290-
"kernelTCP": 0,
292+
"kernel": -1,
293+
"kernelTCP": -1,
291294
"swappiness": 0
292295
}
293296
```

config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,8 @@ Here is a full example `config.json` for reference.
689689
"limit": 536870912,
690690
"reservation": 536870912,
691691
"swap": 536870912,
692-
"kernel": 0,
693-
"kernelTCP": 0,
692+
"kernel": -1,
693+
"kernelTCP": -1,
694694
"swappiness": 0
695695
},
696696
"cpu": {

schema/config-linux.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,23 +172,23 @@
172172
"properties": {
173173
"kernel": {
174174
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/kernel",
175-
"$ref": "defs.json#/definitions/uint64"
175+
"$ref": "defs.json#/definitions/int64"
176176
},
177177
"kernelTCP": {
178178
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/kernelTCP",
179-
"$ref": "defs.json#/definitions/uint64"
179+
"$ref": "defs.json#/definitions/int64"
180180
},
181181
"limit": {
182182
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/limit",
183-
"$ref": "defs.json#/definitions/uint64"
183+
"$ref": "defs.json#/definitions/int64"
184184
},
185185
"reservation": {
186186
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/reservation",
187-
"$ref": "defs.json#/definitions/uint64"
187+
"$ref": "defs.json#/definitions/int64"
188188
},
189189
"swap": {
190190
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/swap",
191-
"$ref": "defs.json#/definitions/uint64"
191+
"$ref": "defs.json#/definitions/int64"
192192
},
193193
"swappiness": {
194194
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/swappiness",

schema/test/config/good/spec-example.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@
239239
"limit": 536870912,
240240
"reservation": 536870912,
241241
"swap": 536870912,
242-
"kernel": 0,
243-
"kernelTCP": 0,
242+
"kernel": -1,
243+
"kernelTCP": -1,
244244
"swappiness": 0
245245
},
246246
"cpu": {

specs-go/config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,15 @@ type LinuxBlockIO struct {
273273
// LinuxMemory for Linux cgroup 'memory' resource management
274274
type LinuxMemory struct {
275275
// Memory limit (in bytes).
276-
Limit *uint64 `json:"limit,omitempty"`
276+
Limit *int64 `json:"limit,omitempty"`
277277
// Memory reservation or soft_limit (in bytes).
278-
Reservation *uint64 `json:"reservation,omitempty"`
278+
Reservation *int64 `json:"reservation,omitempty"`
279279
// Total memory limit (memory + swap).
280-
Swap *uint64 `json:"swap,omitempty"`
280+
Swap *int64 `json:"swap,omitempty"`
281281
// Kernel memory limit (in bytes).
282-
Kernel *uint64 `json:"kernel,omitempty"`
282+
Kernel *int64 `json:"kernel,omitempty"`
283283
// Kernel memory limit for tcp (in bytes)
284-
KernelTCP *uint64 `json:"kernelTCP,omitempty"`
284+
KernelTCP *int64 `json:"kernelTCP,omitempty"`
285285
// How aggressive the kernel will swap memory pages.
286286
Swappiness *uint64 `json:"swappiness,omitempty"`
287287
}

0 commit comments

Comments
 (0)