Skip to content

Commit 7a49e34

Browse files
Merge pull request #1011 from odinuge/hugetlb-pattern
config-linux: add more info about hugetlb page size
2 parents 8ffda14 + 759f58a commit 7a49e34

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

config-linux.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ For more information, see the kernel cgroups documentation about [HugeTLB][cgrou
394394
Each entry has the following structure:
395395

396396
* **`pageSize`** *(string, REQUIRED)* - hugepage size
397+
The value has the format "<size><unit-prefix>B" (64KB, 2MB, 1GB), and must match the <hugepagesize> of the
398+
corresponding control file found in "/sys/fs/cgroup/hugetlb/hugetlb.<hugepagesize>.limit_in_bytes".
399+
Values of <unit-prefix> are intended to be parsed using base 1024 ("1KB" = 1024, "1MB" = 1048576, etc).
397400
* **`limit`** *(uint64, REQUIRED)* - limit in bytes of *hugepagesize* HugeTLB usage
398401

399402
#### Example
@@ -403,6 +406,10 @@ Each entry has the following structure:
403406
{
404407
"pageSize": "2MB",
405408
"limit": 209715200
409+
},
410+
{
411+
"pageSize": "64KB",
412+
"limit": 1000000
406413
}
407414
]
408415
```

config.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,10 @@ Here is a full example `config.json` for reference.
710710
{
711711
"pageSize": "2MB",
712712
"limit": 9223372036854772000
713+
},
714+
{
715+
"pageSize": "64KB",
716+
"limit": 1000000
713717
}
714718
],
715719
"memory": {

schema/config-linux.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@
124124
"type": "object",
125125
"properties": {
126126
"pageSize": {
127-
"type": "string"
127+
"type": "string",
128+
"pattern": "^[1-9][0-9]*[KMG]B$"
128129
},
129130
"limit": {
130131
"$ref": "defs.json#/definitions/uint64"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"ociVersion": "1.0.0",
3+
"root": {
4+
"path": "rootfs"
5+
},
6+
"linux": {
7+
"resources": {
8+
"hugepageLimits": [
9+
{
10+
"limit": 1234123,
11+
"pageSize": "64kB"
12+
}
13+
]
14+
}
15+
}
16+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@
232232
{
233233
"pageSize": "2MB",
234234
"limit": 9223372036854772000
235+
},
236+
{
237+
"pageSize": "64KB",
238+
"limit": 1000000
235239
}
236240
],
237241
"oomScoreAdj": 100,

specs-go/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ type POSIXRlimit struct {
219219
// LinuxHugepageLimit structure corresponds to limiting kernel hugepages
220220
type LinuxHugepageLimit struct {
221221
// Pagesize is the hugepage size
222+
// Format: "<size><unit-prefix>B' (e.g. 64KB, 2MB, 1GB, etc.)
222223
Pagesize string `json:"pageSize"`
223224
// Limit is the limit of "hugepagesize" hugetlb usage
224225
Limit uint64 `json:"limit"`

0 commit comments

Comments
 (0)