Re: [PATCH] mm: memcg: dump memcg protection info on oom or alloc failures

From: SeongJae Park

Date: Fri Nov 07 2025 - 21:26:47 EST


On Fri, 7 Nov 2025 15:40:41 -0800 Shakeel Butt <shakeel.butt@xxxxxxxxx> wrote:

> Currently kernel dumps memory state on oom and allocation failures. One
> of the question usually raised on those dumps is why the kernel has not
> reclaimed the reclaimable memory instead of triggering oom. One
> potential reason is the usage of memory protection provided by memcg.
> So, let's also dump the memory protected by the memcg in such reports to
> ease the debugging.
>
> Signed-off-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>
> ---
[...]
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index c34029e92bab..623446821b00 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -5636,3 +5636,16 @@ bool mem_cgroup_node_allowed(struct mem_cgroup *memcg, int nid)
> {
> return memcg ? cpuset_node_allowed(memcg->css.cgroup, nid) : true;
> }
> +
> +void mem_cgroup_show_protected_memory(struct mem_cgroup *memcg)
> +{
> + if (mem_cgroup_disabled() || !cgroup_subsys_on_dfl(memory_cgrp_subsys))
> + return;
> +
> + if (!memcg)
> + memcg = root_mem_cgroup;
> +
> + pr_warn("Memory cgroup min protection %lukB -- low protection %lukB",
> + K(atomic_long_read(&memcg->memory.children_min_usage)*PAGE_SIZE),
> + K(atomic_long_read(&memcg->memory.children_low_usage)*PAGE_SIZE));
> +}

I didn't expect this function is showing the information by calling pr_warn().
To me, "show" feels like something for file operations, like memory_min_show().

What about s/show/dump/ on the name? It makes it more consistent with the
subject of this patch, and other similar functions like dump_page() ?

No strong opinion. The current name is also ok for me, but I'm just curious your thought.


Thanks,
SJ

[...]