xref: /linux/Documentation/admin-guide/cgroup-v1/hugetlb.rst (revision 17cfcb68af3bc7d5e8ae08779b1853310a2949f3)
1==================
2HugeTLB Controller
3==================
4
5The HugeTLB controller allows to limit the HugeTLB usage per control group and
6enforces the controller limit during page fault. Since HugeTLB doesn't
7support page reclaim, enforcing the limit at page fault time implies that,
8the application will get SIGBUS signal if it tries to access HugeTLB pages
9beyond its limit. This requires the application to know beforehand how much
10HugeTLB pages it would require for its use.
11
12HugeTLB controller can be created by first mounting the cgroup filesystem.
13
14# mount -t cgroup -o hugetlb none /sys/fs/cgroup
15
16With the above step, the initial or the parent HugeTLB group becomes
17visible at /sys/fs/cgroup. At bootup, this group includes all the tasks in
18the system. /sys/fs/cgroup/tasks lists the tasks in this cgroup.
19
20New groups can be created under the parent group /sys/fs/cgroup::
21
22  # cd /sys/fs/cgroup
23  # mkdir g1
24  # echo $$ > g1/tasks
25
26The above steps create a new group g1 and move the current shell
27process (bash) into it.
28
29Brief summary of control files::
30
31 hugetlb.<hugepagesize>.limit_in_bytes     # set/show limit of "hugepagesize" hugetlb usage
32 hugetlb.<hugepagesize>.max_usage_in_bytes # show max "hugepagesize" hugetlb  usage recorded
33 hugetlb.<hugepagesize>.usage_in_bytes     # show current usage for "hugepagesize" hugetlb
34 hugetlb.<hugepagesize>.failcnt		   # show the number of allocation failure due to HugeTLB limit
35
36For a system supporting three hugepage sizes (64k, 32M and 1G), the control
37files include::
38
39  hugetlb.1GB.limit_in_bytes
40  hugetlb.1GB.max_usage_in_bytes
41  hugetlb.1GB.usage_in_bytes
42  hugetlb.1GB.failcnt
43  hugetlb.64KB.limit_in_bytes
44  hugetlb.64KB.max_usage_in_bytes
45  hugetlb.64KB.usage_in_bytes
46  hugetlb.64KB.failcnt
47  hugetlb.32MB.limit_in_bytes
48  hugetlb.32MB.max_usage_in_bytes
49  hugetlb.32MB.usage_in_bytes
50  hugetlb.32MB.failcnt
51