Skip to content

Commit 8a09257

Browse files
authored
Merge pull request #1116 from kailun-qin/add-hugetlb-rsvd
config-linux: add support for rsvd hugetlb cgroup
2 parents 9067ce6 + a650533 commit 8a09257

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

config-linux.md

+19-5
Original file line numberDiff line numberDiff line change
@@ -483,17 +483,31 @@ The following parameters can be specified to set up the controller:
483483

484484
### <a name="configLinuxHugePageLimits" />Huge page limits
485485

486-
**`hugepageLimits`** (array of objects, OPTIONAL) represents the `hugetlb` controller which allows to limit the
487-
HugeTLB usage per control group and enforces the controller limit during page fault.
486+
**`hugepageLimits`** (array of objects, OPTIONAL) represents the `hugetlb` controller which allows to limit the HugeTLB reservations (if supported) or usage (page fault).
487+
By default if supported by the kernel, `hugepageLimits` defines the hugepage sizes and limits for HugeTLB controller
488+
reservation accounting, which allows to limit the HugeTLB reservations per control group and enforces the controller
489+
limit at reservation time and at the fault of HugeTLB memory for which no reservation exists.
490+
Otherwise if not supported by the kernel, this should fallback to the page fault accounting, which allows users to limit
491+
the HugeTLB usage (page fault) per control group and enforces the limit during page fault.
492+
493+
Note that reservation limits are superior to page fault limits, since reservation limits are enforced at reservation
494+
time (on mmap or shget), and never causes the application to get SIGBUS signal if the memory was reserved before hand.
495+
This allows for easier fallback to alternatives such as non-HugeTLB memory for example. In the case of page fault
496+
accounting, it's very hard to avoid processes getting SIGBUS since the sysadmin needs precisely know the HugeTLB usage
497+
of all the tasks in the system and make sure there is enough pages to satisfy all requests. Avoiding tasks getting
498+
SIGBUS on overcommited systems is practically impossible with page fault accounting.
499+
488500
For more information, see the kernel cgroups documentation about [HugeTLB][cgroup-v1-hugetlb].
489501

490502
Each entry has the following structure:
491503

492-
* **`pageSize`** *(string, REQUIRED)* - hugepage size
504+
* **`pageSize`** *(string, REQUIRED)* - hugepage size.
493505
The value has the format `<size><unit-prefix>B` (64KB, 2MB, 1GB), and must match the `<hugepagesize>` of the
494-
corresponding control file found in `/sys/fs/cgroup/hugetlb/hugetlb.<hugepagesize>.limit_in_bytes`.
506+
corresponding control file found in `/sys/fs/cgroup/hugetlb/hugetlb.<hugepagesize>.rsvd.limit_in_bytes` (if
507+
hugetlb_cgroup reservation is supported) or `/sys/fs/cgroup/hugetlb/hugetlb.<hugepagesize>.limit_in_bytes` (if not
508+
supported).
495509
Values of `<unit-prefix>` are intended to be parsed using base 1024 ("1KB" = 1024, "1MB" = 1048576, etc).
496-
* **`limit`** *(uint64, REQUIRED)* - limit in bytes of *hugepagesize* HugeTLB usage
510+
* **`limit`** *(uint64, REQUIRED)* - limit in bytes of *hugepagesize* HugeTLB reservations (if supported) or usage.
497511

498512
#### Example
499513

specs-go/config.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,13 @@ type POSIXRlimit struct {
254254
Soft uint64 `json:"soft"`
255255
}
256256

257-
// LinuxHugepageLimit structure corresponds to limiting kernel hugepages
257+
// LinuxHugepageLimit structure corresponds to limiting kernel hugepages.
258+
// Default to reservation limits if supported. Otherwise fallback to page fault limits.
258259
type LinuxHugepageLimit struct {
259-
// Pagesize is the hugepage size
260-
// Format: "<size><unit-prefix>B' (e.g. 64KB, 2MB, 1GB, etc.)
260+
// Pagesize is the hugepage size.
261+
// Format: "<size><unit-prefix>B' (e.g. 64KB, 2MB, 1GB, etc.).
261262
Pagesize string `json:"pageSize"`
262-
// Limit is the limit of "hugepagesize" hugetlb usage
263+
// Limit is the limit of "hugepagesize" hugetlb reservations (if supported) or usage.
263264
Limit uint64 `json:"limit"`
264265
}
265266

@@ -394,7 +395,7 @@ type LinuxResources struct {
394395
Pids *LinuxPids `json:"pids,omitempty"`
395396
// BlockIO restriction configuration
396397
BlockIO *LinuxBlockIO `json:"blockIO,omitempty"`
397-
// Hugetlb limit (in bytes)
398+
// Hugetlb limits (in bytes). Default to reservation limits if supported.
398399
HugepageLimits []LinuxHugepageLimit `json:"hugepageLimits,omitempty"`
399400
// Network restriction configuration
400401
Network *LinuxNetwork `json:"network,omitempty"`

0 commit comments

Comments
 (0)