Skip to contentSkip to conversation

memcg: Add kmem.slabinfo to v2 for debugging purpose

PATCH In review Waiman Long 3 participants 5 messages Jun 26, 2019 – Jun 27, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memcg: Add kmem.slabinfo to v2 for debugging purpose

With memory cgroup v1, there is a kmem.slabinfo file that can be used to view what slabs are allocated to the memory cgroup. There is currently no such equivalent in memory cgroup v2. This file can be useful for debugging purpose.

This patch adds an equivalent kmem.slabinfo to v2 with the caveat that this file will only show up as ".__DEBUG__.memory.kmem.slabinfo" when the "cgroup_debug" parameter is specified in the kernel boot command line. This is to avoid cluttering the cgroup v2 interface with files that are seldom used by end users.

---
 mm/memcontrol.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
mm/memcontrol.c +16 -0
index ba9138a4a1de..236554a23f8f 100644
@@ -5812,6 +5812,22 @@ static struct cftype memory_files[] = {
 		.seq_show = memory_oom_group_show,
 		.write = memory_oom_group_write,
 	},
+#ifdef CONFIG_MEMCG_KMEM
+	{
+		/*
+		 * This file is for debugging purpose only and will show
+		 * up as ".__DEBUG__.memory.kmem.slabinfo" when the
+		 * "cgroup_debug" parameter is specified in the kernel
+		 * boot command line.
+		 */
+		.name = "kmem.slabinfo",
+		.flags = CFTYPE_NOT_ON_ROOT | CFTYPE_DEBUG,
+		.seq_start = memcg_slab_start,
+		.seq_next = memcg_slab_next,
+		.seq_stop = memcg_slab_stop,
+		.seq_show = memcg_slab_show,
+	},
+#endif
 	{ }	/* terminate */
 };
 
Signature · 1 line
2.18.1
maintainer
#1 lore raw
Quoted 11 lines · On Wed, 26 Jun 2019 12:56:14 -0400 Waiman Long <[email protected]> wrote:

With memory cgroup v1, there is a kmem.slabinfo file that can be used to view what slabs are allocated to the memory cgroup. There is currently no such equivalent in memory cgroup v2. This file can be useful for debugging purpose.

This patch adds an equivalent kmem.slabinfo to v2 with the caveat that this file will only show up as ".__DEBUG__.memory.kmem.slabinfo" when the "cgroup_debug" parameter is specified in the kernel boot command line. This is to avoid cluttering the cgroup v2 interface with files that are seldom used by end users.

Quoted 4 lines

...

mm/memcontrol.c | 16 ++++++++++++++++

1 file changed, 16 insertions(+)

A change to the kernel's user interface triggers a change to the kernel's user interface documentation. This should be automatic by now :(

#2 lore raw
Quoted 13 lines · Andrew Morton
Quoted 11 lines · On Wed, 26 Jun 2019 12:56:14 -0400 Waiman Long <[email protected]> wrote:

With memory cgroup v1, there is a kmem.slabinfo file that can be used to view what slabs are allocated to the memory cgroup. There is currently no such equivalent in memory cgroup v2. This file can be useful for debugging purpose.

This patch adds an equivalent kmem.slabinfo to v2 with the caveat that this file will only show up as ".__DEBUG__.memory.kmem.slabinfo" when the "cgroup_debug" parameter is specified in the kernel boot command line. This is to avoid cluttering the cgroup v2 interface with files that are seldom used by end users.

Quoted 9 lines
Quoted 4 lines

...

mm/memcontrol.c | 16 ++++++++++++++++

1 file changed, 16 insertions(+)

A change to the kernel's user interface triggers a change to the kernel's user interface documentation. This should be automatic by now :(

We don't usually document debugging only files as they are subject to change with no stability guarantee. That is the point of marking it for debugging instead of a regular file that we need to support forever.

Cheers,
Longman

maintainer
#3 lore raw
In reply to Waiman Long

Hello, Waiman.

Quoted 10 lines · Waiman Long

With memory cgroup v1, there is a kmem.slabinfo file that can be used to view what slabs are allocated to the memory cgroup. There is currently no such equivalent in memory cgroup v2. This file can be useful for debugging purpose.

This patch adds an equivalent kmem.slabinfo to v2 with the caveat that this file will only show up as ".__DEBUG__.memory.kmem.slabinfo" when the "cgroup_debug" parameter is specified in the kernel boot command line. This is to avoid cluttering the cgroup v2 interface with files that are seldom used by end users.

Can you please take a look at drgn?

https://github.com/osandov/drgn

Baking in debug interface files always is limited and nasty and drgn can get you way more flexible debugging / monitoring tool w/o having to bake in anything into the kernel. For an example, please take a look at

https://lore.kernel.org/bpf/[email protected]/

Thanks.

Signature · 1 line
tejun
#4 lore raw
Quoted 17 lines · Tejun Heo

Hello, Waiman.

Quoted 10 lines · Waiman Long

With memory cgroup v1, there is a kmem.slabinfo file that can be used to view what slabs are allocated to the memory cgroup. There is currently no such equivalent in memory cgroup v2. This file can be useful for debugging purpose.

This patch adds an equivalent kmem.slabinfo to v2 with the caveat that this file will only show up as ".__DEBUG__.memory.kmem.slabinfo" when the "cgroup_debug" parameter is specified in the kernel boot command line. This is to avoid cluttering the cgroup v2 interface with files that are seldom used by end users.

Can you please take a look at drgn?

https://github.com/osandov/drgn

Quoted 9 lines

Baking in debug interface files always is limited and nasty and drgn can get you way more flexible debugging / monitoring tool w/o having to bake in anything into the kernel. For an example, please take a look at

https://lore.kernel.org/bpf/[email protected]/

Thanks.

Thanks for the information. Will take a serious look at that.

Cheers,
Longman