Skip to content

Commit

Permalink
mm/hugetlb_cgroup: introduce peak and rsvd.peak to v2
Browse files Browse the repository at this point in the history
Introduce peak and rsvd.peak to v2 to show the historical maximum usage of
resources, as in some scenarios it is necessary to configure the value of
max/rsvd.max based on the peak usage of resources.

Since HugeTLB doesn't support page reclaim, enforcing the limit at page
fault time implies that, the application will get SIGBUS signal if it
tries to fault in HugeTLB pages beyond its limit.  Therefore the
application needs to know exactly how many HugeTLB pages it uses before
hand, and the sysadmin needs to make sure that there are enough available
on the machine for all the users to avoid processes getting SIGBUS.

When running some open-source software, it may not be possible to know the
exact amount of hugetlb it consumes, so cannot correctly configure the max
value.  If there is a peak metric, we can run the open-source software
first and then configure the max based on the peak value.  In cgroup v1,
the hugetlb controller provides the max_usage_in_bytes and
rsvd.max_usage_in_bytes interface to display the historical maximum usage,
so introduce peak and rsvd.peak to v2 to address this issue.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Xiu Jianfeng <[email protected]>
Cc: Baolin Wang <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Miaohe Lin <[email protected]>
Cc: Sidhartha Kumar <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Zefan Li <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Xiu Jianfeng authored and akpm00 committed Sep 30, 2024
1 parent e9c2d32 commit b795e06
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Documentation/admin-guide/cgroup-v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2645,6 +2645,14 @@ HugeTLB Interface Files
hugetlb pages of <hugepagesize> in this cgroup. Only active in
use hugetlb pages are included. The per-node values are in bytes.

hugetlb.<hugepagesize>.peak
Show historical maximum usage for "hugepagesize" hugetlb. It exists
for all the cgroup except root.

hugetlb.<hugepagesize>.rsvd.peak
Show historical maximum usage for "hugepagesize" hugetlb reservations.
It exists for all the cgroup except root.

Misc
----

Expand Down
19 changes: 19 additions & 0 deletions mm/hugetlb_cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,13 @@ static int hugetlb_cgroup_read_u64_max(struct seq_file *seq, void *v)
else
seq_printf(seq, "%llu\n", val * PAGE_SIZE);
break;
case RES_RSVD_MAX_USAGE:
counter = &h_cg->rsvd_hugepage[idx];
fallthrough;
case RES_MAX_USAGE:
val = (u64)counter->watermark;
seq_printf(seq, "%llu\n", val * PAGE_SIZE);
break;
default:
BUG();
}
Expand Down Expand Up @@ -739,6 +746,18 @@ static struct cftype hugetlb_dfl_tmpl[] = {
.seq_show = hugetlb_cgroup_read_u64_max,
.flags = CFTYPE_NOT_ON_ROOT,
},
{
.name = "peak",
.private = RES_MAX_USAGE,
.seq_show = hugetlb_cgroup_read_u64_max,
.flags = CFTYPE_NOT_ON_ROOT,
},
{
.name = "rsvd.peak",
.private = RES_RSVD_MAX_USAGE,
.seq_show = hugetlb_cgroup_read_u64_max,
.flags = CFTYPE_NOT_ON_ROOT,
},
{
.name = "events",
.seq_show = hugetlb_events_show,
Expand Down

0 comments on commit b795e06

Please sign in to comment.