linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Yang Shi" <yang.s@alibaba-inc.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] mm: oom: show unreclaimable slab info when kernel panic
Date: Sat, 16 Sep 2017 01:40:17 +0800	[thread overview]
Message-ID: <ade43170-d968-4bd1-bc2d-61bafc3bc88e@alibaba-inc.com> (raw)
In-Reply-To: <2f7b69d1-8aa2-c2b8-92bd-167998145a28@I-love.SAKURA.ne.jp>



On 9/15/17 5:00 AM, Tetsuo Handa wrote:
> On 2017/09/15 2:14, Yang Shi wrote:
>> @@ -1274,6 +1276,29 @@ 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");
>> +	mutex_lock(&slab_mutex);
> 
> Please avoid sleeping locks which potentially depend on memory allocation.
> There are
> 
> 	mutex_lock(&slab_mutex);
> 	kmalloc(GFP_KERNEL);
> 	mutex_unlock(&slab_mutex);
> 
> users which will fail to call panic() if they hit this path
Thanks for the heads up. Since this is just called by oom in panic path, 
so it sounds safe to just discard the mutex_lock()/mutex_unlock call 
since nobody can allocate memory without GFP_ATOMIC to change the 
statistics of slab.

Even though some GFP_ATOMIC callers allocate memory successfully, it 
should not have obvious impact to the slabinfo we need capture since 
typically GFP_ATOMIC allocation is small.

I will drop the mutext in v2 if no one has objection.

Thanks,
Yang

> 
>> +	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));
>> +	}
>> +	mutex_unlock(&slab_mutex);
>> +}
>> +EXPORT_SYMBOL(show_unreclaimable_slab);
>> +#undef K
>> +
>>   #if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
>>   void *memcg_slab_start(struct seq_file *m, loff_t *pos)
>>   {
>>

--
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-15 17:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-14 17:14 [RFC] oom: capture unreclaimable slab info in oom message " Yang Shi
2017-09-14 17:14 ` [PATCH 1/3] mm: slab: output reclaimable flag in /proc/slabinfo Yang Shi
2017-09-14 17:27   ` Christopher Lameter
2017-09-14 17:53     ` Yang Shi
2017-09-14 17:14 ` [PATCH 2/3] tools: slabinfo: add "-U" option to show unreclaimable slabs only Yang Shi
2017-09-14 17:28   ` Christopher Lameter
2017-09-14 17:14 ` [PATCH 3/3] mm: oom: show unreclaimable slab info when kernel panic Yang Shi
2017-09-14 17:32   ` Christopher Lameter
2017-09-14 17:48     ` Yang Shi
2017-09-15 12:00   ` Tetsuo Handa
2017-09-15 17:40     ` Yang Shi [this message]

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=ade43170-d968-4bd1-bc2d-61bafc3bc88e@alibaba-inc.com \
    --to=yang.s@alibaba-inc.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=penberg@kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=rientjes@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox