linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: SeongJae Park <sj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	Muchun Song <muchun.song@linux.dev>,
	 David Rientjes <rientjes@google.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	linux-mm@kvack.org,  cgroups@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	 Meta kernel team <kernel-team@meta.com>
Subject: Re: [PATCH] mm: memcg: dump memcg protection info on oom or alloc failures
Date: Fri, 7 Nov 2025 21:45:04 -0800	[thread overview]
Message-ID: <tawekrqql6efopwac3zrqgrszueampnadqp7s3g7wfvohsiqbt@22ai2cryardu> (raw)
In-Reply-To: <20251108022639.73734-1-sj@kernel.org>

On Fri, Nov 07, 2025 at 06:26:38PM -0800, SeongJae Park wrote:
> On Fri,  7 Nov 2025 15:40:41 -0800 Shakeel Butt <shakeel.butt@linux.dev> 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@linux.dev>
> > ---
> [...]
> > 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.
> 

I just took the inspiration from show_mem(). Initially I was trying to
put these pr_warn in show_mem() but noticed that it was called from more
places than I intend to print this info, so decided to have a separate
function.

Thanks for taking a look.


  reply	other threads:[~2025-11-08  5:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07 23:40 Shakeel Butt
2025-11-08  2:26 ` SeongJae Park
2025-11-08  5:45   ` Shakeel Butt [this message]
2025-11-10  8:48 ` Michal Hocko
2025-11-10  8:57 ` Vlastimil Babka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tawekrqql6efopwac3zrqgrszueampnadqp7s3g7wfvohsiqbt@22ai2cryardu \
    --to=shakeel.butt@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=sj@kernel.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox