1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
From a7ffb15d099b431ef67c49d369530bd5a6f48802 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj@kernel.org>
Date: Fri, 18 Nov 2022 23:50:59 +0000
Subject: [PATCH] mm/damon/sysfs: Add a file for simple checking memcg ids and
paths
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 6fee383bc0c5..bc6204d66755 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1885,7 +1885,33 @@ static void damon_sysfs_ui_dir_release(struct kobject *kobj)
kfree(container_of(kobj, struct damon_sysfs_ui_dir, kobj));
}
+static ssize_t debug_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+#ifdef CONFIG_MEMCG
+ struct mem_cgroup *memcg;
+ char *path = kmalloc(sizeof(*path) * PATH_MAX, GFP_KERNEL);
+
+ if (!path)
+ return -ENOMEM;
+
+ for (memcg = mem_cgroup_iter(NULL, NULL, NULL); memcg; memcg =
+ mem_cgroup_iter(NULL, memcg, NULL)) {
+ cgroup_path(memcg->css.cgroup, path, PATH_MAX);
+ pr_info("id: %u, path: %s\n", mem_cgroup_id(memcg), path);
+ }
+
+ kfree(path);
+#endif
+
+ return 0;
+}
+
+static struct kobj_attribute damon_sysfs_debug_attr =
+ __ATTR_RO_MODE(debug, 0400);
+
static struct attribute *damon_sysfs_ui_dir_attrs[] = {
+ &damon_sysfs_debug_attr.attr,
NULL,
};
ATTRIBUTE_GROUPS(damon_sysfs_ui_dir);
--
2.39.2
|