linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] mm/hugetlb_cgroup: introduce peak and rsvd.peak to v2
@ 2024-07-02 12:57 Xiu Jianfeng
  2024-07-03  1:58 ` Andrew Morton
  2024-12-01  6:52 ` Andrew Morton
  0 siblings, 2 replies; 10+ messages in thread
From: Xiu Jianfeng @ 2024-07-02 12:57 UTC (permalink / raw)
  To: tj, lizefan.x, hannes, corbet, akpm
  Cc: cgroups, linux-doc, linux-kernel, linux-mm

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.

Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
 Documentation/admin-guide/cgroup-v2.rst |  8 ++++++++
 mm/hugetlb_cgroup.c                     | 19 +++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index ae0fdb6fc618..97d19968230a 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -2607,6 +2607,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
 ----
 
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index 4ff238ba1250..f443a56409a9 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -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();
 	}
@@ -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,
-- 
2.34.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-12-01  6:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-02 12:57 [PATCH -next] mm/hugetlb_cgroup: introduce peak and rsvd.peak to v2 Xiu Jianfeng
2024-07-03  1:58 ` Andrew Morton
2024-07-03  2:45   ` xiujianfeng
2024-07-03 20:38     ` Andrew Morton
2024-07-08 12:48       ` Michal Hocko
2024-07-08 13:40         ` xiujianfeng
2024-07-08 16:04           ` Michal Hocko
2024-07-09 12:47             ` xiujianfeng
2024-07-09 13:05               ` Michal Hocko
2024-12-01  6:52 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox