linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memcg: Add kmem.slabinfo to v2 for debugging purpose
@ 2019-06-26 16:56 Waiman Long
  2019-06-26 22:25 ` Andrew Morton
  2019-06-27 14:20 ` Tejun Heo
  0 siblings, 2 replies; 5+ messages in thread
From: Waiman Long @ 2019-06-26 16:56 UTC (permalink / raw)
  To: Johannes Weiner, Michal Hocko, Vladimir Davydov, Tejun Heo
  Cc: linux-kernel, cgroups, linux-mm, Andrew Morton, Shakeel Butt,
	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.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 mm/memcontrol.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ba9138a4a1de..236554a23f8f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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 */
 };
 
-- 
2.18.1


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

* Re: [PATCH] memcg: Add kmem.slabinfo to v2 for debugging purpose
  2019-06-26 16:56 [PATCH] memcg: Add kmem.slabinfo to v2 for debugging purpose Waiman Long
@ 2019-06-26 22:25 ` Andrew Morton
  2019-06-27 13:47   ` Waiman Long
  2019-06-27 14:20 ` Tejun Heo
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2019-06-26 22:25 UTC (permalink / raw)
  To: Waiman Long
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov, Tejun Heo,
	linux-kernel, cgroups, linux-mm, Shakeel Butt

On Wed, 26 Jun 2019 12:56:14 -0400 Waiman Long <longman@redhat.com> 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.
>
> ...
>
> 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 :(



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

* Re: [PATCH] memcg: Add kmem.slabinfo to v2 for debugging purpose
  2019-06-26 22:25 ` Andrew Morton
@ 2019-06-27 13:47   ` Waiman Long
  0 siblings, 0 replies; 5+ messages in thread
From: Waiman Long @ 2019-06-27 13:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov, Tejun Heo,
	linux-kernel, cgroups, linux-mm, Shakeel Butt

On 6/26/19 6:25 PM, Andrew Morton wrote:
> On Wed, 26 Jun 2019 12:56:14 -0400 Waiman Long <longman@redhat.com> 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.
>>
>> ...
>>
>> 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


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

* Re: [PATCH] memcg: Add kmem.slabinfo to v2 for debugging purpose
  2019-06-26 16:56 [PATCH] memcg: Add kmem.slabinfo to v2 for debugging purpose Waiman Long
  2019-06-26 22:25 ` Andrew Morton
@ 2019-06-27 14:20 ` Tejun Heo
  2019-06-27 20:59   ` Waiman Long
  1 sibling, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2019-06-27 14:20 UTC (permalink / raw)
  To: Waiman Long
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov, linux-kernel,
	cgroups, linux-mm, Andrew Morton, Shakeel Butt

Hello, Waiman.

On Wed, Jun 26, 2019 at 12:56:14PM -0400, Waiman Long 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.

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/20190614015620.1587672-10-tj@kernel.org/

Thanks.

-- 
tejun


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

* Re: [PATCH] memcg: Add kmem.slabinfo to v2 for debugging purpose
  2019-06-27 14:20 ` Tejun Heo
@ 2019-06-27 20:59   ` Waiman Long
  0 siblings, 0 replies; 5+ messages in thread
From: Waiman Long @ 2019-06-27 20:59 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov, linux-kernel,
	cgroups, linux-mm, Andrew Morton, Shakeel Butt

On 6/27/19 10:20 AM, Tejun Heo wrote:
> Hello, Waiman.
>
> On Wed, Jun 26, 2019 at 12:56:14PM -0400, Waiman Long 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.
> 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/20190614015620.1587672-10-tj@kernel.org/
>
> Thanks.
>
Thanks for the information. Will take a serious look at that.

Cheers,
Longman


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

end of thread, other threads:[~2019-06-27 20:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26 16:56 [PATCH] memcg: Add kmem.slabinfo to v2 for debugging purpose Waiman Long
2019-06-26 22:25 ` Andrew Morton
2019-06-27 13:47   ` Waiman Long
2019-06-27 14:20 ` Tejun Heo
2019-06-27 20:59   ` Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).