All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Yang Shi <yang.s@alibaba-inc.com>
Cc: cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com,
	akpm@linux-foundation.org, mhocko@kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm: oom: show unreclaimable slab info when kernel panic
Date: Tue, 19 Sep 2017 15:41:12 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.10.1709191539010.137005@chino.kir.corp.google.com> (raw)
In-Reply-To: <01f4cce4-d7a3-2fcb-06e0-382eff8e83e5@alibaba-inc.com>

On Wed, 20 Sep 2017, Yang Shi wrote:

> > > --- a/mm/slab_common.c
> > > +++ b/mm/slab_common.c
> > > @@ -35,6 +35,8 @@
> > >   static DECLARE_WORK(slab_caches_to_rcu_destroy_work,
> > >   		    slab_caches_to_rcu_destroy_workfn);
> > >   +#define K(x) ((x)/1024)
> > > +
> > >   /*
> > >    * Set of flags that will prevent slab merging
> > >    */
> > > @@ -1272,6 +1274,34 @@ static int slab_show(struct seq_file *m, void *p)
> > >   	return 0;
> > >   }
> > >   +void show_unreclaimable_slab()
> > > +{
> > > +	struct kmem_cache *s = NULL;
> > > +	struct slabinfo sinfo;
> > > +
> > > +	memset(&sinfo, 0, sizeof(sinfo));
> > > +
> > > +	printk("Unreclaimable slabs:\n");
> > > +
> > > +	/*
> > > +	 * Here acquiring slab_mutex is unnecessary since we don't prefer to
> > > +	 * get sleep in oom path right before kernel panic, and avoid race
> > > condition.
> > > +	 * Since it is already oom, so there should be not any big allocation
> > > +	 * which could change the statistics significantly.
> > > +	 */
> > > +	list_for_each_entry(s, &slab_caches, list) {
> > > +		if (!is_root_cache(s))
> > > +			continue;
> > > +
> > > +		get_slabinfo(s, &sinfo);
> > > +
> > > +		if (!is_reclaimable(s) && sinfo.num_objs > 0)
> > > +			printk("%-17s %luKB\n", cache_name(s),
> > > K(sinfo.num_objs * s->size));
> > > +	}
> > 
> > I like this, but could we be even more helpful by giving the user more
> > information from sinfo beyond just the total size of objects allocated?
> 
> Sure, we definitely can. But, the question is what info is helpful to users to
> diagnose oom other than the size.
> 
> I think of the below:
> 	- the number of active objs, the number of total objs, the percentage
> of active objs per cache
> 	- the number of active slabs, the number of total slabs, the
> percentage of active slabs per cache
> 
> Anything else?
> 

Right now it's a useful tool to find out what unreclaimable slab is 
sitting around that is causing the system to run out of memory.  If we 
knew how much of this slab is actually in use vs free, it can determine if 
its stranding or if there's a bug in the slab allocator itself.

We wouldn't need percentages, we can calculate that directly from the 
data if necessary.

WARNING: multiple messages have this Message-ID (diff)
From: David Rientjes <rientjes@google.com>
To: Yang Shi <yang.s@alibaba-inc.com>
Cc: cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com,
	akpm@linux-foundation.org, mhocko@kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm: oom: show unreclaimable slab info when kernel panic
Date: Tue, 19 Sep 2017 15:41:12 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.10.1709191539010.137005@chino.kir.corp.google.com> (raw)
In-Reply-To: <01f4cce4-d7a3-2fcb-06e0-382eff8e83e5@alibaba-inc.com>

On Wed, 20 Sep 2017, Yang Shi wrote:

> > > --- a/mm/slab_common.c
> > > +++ b/mm/slab_common.c
> > > @@ -35,6 +35,8 @@
> > >   static DECLARE_WORK(slab_caches_to_rcu_destroy_work,
> > >   		    slab_caches_to_rcu_destroy_workfn);
> > >   +#define K(x) ((x)/1024)
> > > +
> > >   /*
> > >    * Set of flags that will prevent slab merging
> > >    */
> > > @@ -1272,6 +1274,34 @@ static int slab_show(struct seq_file *m, void *p)
> > >   	return 0;
> > >   }
> > >   +void show_unreclaimable_slab()
> > > +{
> > > +	struct kmem_cache *s = NULL;
> > > +	struct slabinfo sinfo;
> > > +
> > > +	memset(&sinfo, 0, sizeof(sinfo));
> > > +
> > > +	printk("Unreclaimable slabs:\n");
> > > +
> > > +	/*
> > > +	 * Here acquiring slab_mutex is unnecessary since we don't prefer to
> > > +	 * get sleep in oom path right before kernel panic, and avoid race
> > > condition.
> > > +	 * Since it is already oom, so there should be not any big allocation
> > > +	 * which could change the statistics significantly.
> > > +	 */
> > > +	list_for_each_entry(s, &slab_caches, list) {
> > > +		if (!is_root_cache(s))
> > > +			continue;
> > > +
> > > +		get_slabinfo(s, &sinfo);
> > > +
> > > +		if (!is_reclaimable(s) && sinfo.num_objs > 0)
> > > +			printk("%-17s %luKB\n", cache_name(s),
> > > K(sinfo.num_objs * s->size));
> > > +	}
> > 
> > I like this, but could we be even more helpful by giving the user more
> > information from sinfo beyond just the total size of objects allocated?
> 
> Sure, we definitely can. But, the question is what info is helpful to users to
> diagnose oom other than the size.
> 
> I think of the below:
> 	- the number of active objs, the number of total objs, the percentage
> of active objs per cache
> 	- the number of active slabs, the number of total slabs, the
> percentage of active slabs per cache
> 
> Anything else?
> 

Right now it's a useful tool to find out what unreclaimable slab is 
sitting around that is causing the system to run out of memory.  If we 
knew how much of this slab is actually in use vs free, it can determine if 
its stranding or if there's a bug in the slab allocator itself.

We wouldn't need percentages, we can calculate that directly from the 
data if necessary.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-09-19 22:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 18:26 [RFC v2] oom: capture unreclaimable slab info in oom message when kernel panic Yang Shi
2017-09-18 18:26 ` Yang Shi
2017-09-18 18:26 ` [PATCH 1/2] tools: slabinfo: add "-U" option to show unreclaimable slabs only Yang Shi
2017-09-18 18:26   ` Yang Shi
2017-09-18 18:26 ` [PATCH 2/2] mm: oom: show unreclaimable slab info when kernel panic Yang Shi
2017-09-18 18:26   ` Yang Shi
2017-09-19 20:57   ` David Rientjes
2017-09-19 20:57     ` David Rientjes
2017-09-19 21:45     ` Yang Shi
2017-09-19 21:45       ` Yang Shi
2017-09-19 22:41       ` David Rientjes [this message]
2017-09-19 22:41         ` David Rientjes
2017-09-19 23:03         ` Yang Shi
2017-09-19 23:03           ` Yang Shi
  -- strict thread matches above, loose matches on Subject: below --
2017-09-22 19:52 [PATCH 0/2 v6] oom: capture unreclaimable slab info in oom message " Yang Shi
2017-09-22 19:52 ` [PATCH 2/2] mm: oom: show unreclaimable slab info " Yang Shi
2017-09-22 19:52   ` Yang Shi
2017-09-24  6:10   ` Qixuan Wu
2017-09-24  6:10     ` Qixuan Wu
2017-09-21 20:52 [PATCH 0/2 v5] oom: capture unreclaimable slab info in oom message " Yang Shi
2017-09-21 20:52 ` [PATCH 2/2] mm: oom: show unreclaimable slab info " Yang Shi
2017-09-21 20:52   ` Yang Shi
2017-09-20 22:38 [PATCH 0/2 v4] oom: capture unreclaimable slab info in oom message " Yang Shi
2017-09-20 22:38 ` [PATCH 2/2] mm: oom: show unreclaimable slab info " Yang Shi
2017-09-20 22:38   ` Yang Shi
2017-09-21  8:23   ` David Rientjes
2017-09-21  8:23     ` David Rientjes
2017-09-21 17:51     ` Yang Shi
2017-09-21 17:51       ` Yang Shi
2017-09-20 19:09 [RFC v3] oom: capture unreclaimable slab info in oom message " Yang Shi
2017-09-20 19:09 ` [PATCH 2/2] mm: oom: show unreclaimable slab info " Yang Shi
2017-09-20 19:09   ` Yang Shi
2017-09-20 21:00   ` David Rientjes
2017-09-20 21:00     ` David Rientjes
2017-09-20 21:32     ` Yang Shi
2017-09-20 21:32       ` Yang Shi
2017-09-18 18:23 [PATCH 1/2] tools: slabinfo: add "-U" option to show unreclaimable slabs only Yang Shi
2017-09-18 18:23 ` [PATCH 2/2] mm: oom: show unreclaimable slab info when kernel panic Yang Shi
2017-09-18 18:23   ` Yang Shi

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=alpine.DEB.2.10.1709191539010.137005@chino.kir.corp.google.com \
    --to=rientjes@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=penberg@kernel.org \
    --cc=yang.s@alibaba-inc.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.