Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1732983
| From | "Yang Shi" <yang.s@alibaba-inc.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 3/3] mm: oom: show unreclaimable slab info when kernel panic |
| Date | 2017-09-15 19:50 +0200 |
| Message-ID | <uq2Ux-69v-3@gated-at.bofh.it> (permalink) |
| References | <upFXY-7Vl-5@gated-at.bofh.it> <upFXY-7Vl-3@gated-at.bofh.it> <upXBv-2BE-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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)
>> {
>>
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 3/3] mm: oom: show unreclaimable slab info when kernel panic "Yang Shi" <yang.s@alibaba-inc.com> - 2017-09-14 19:20 +0200
Re: [PATCH 3/3] mm: oom: show unreclaimable slab info when kernel panic Christopher Lameter <cl@linux.com> - 2017-09-14 19:40 +0200
Re: [PATCH 3/3] mm: oom: show unreclaimable slab info when kernel panic "Yang Shi" <yang.s@alibaba-inc.com> - 2017-09-14 19:50 +0200
Re: [PATCH 3/3] mm: oom: show unreclaimable slab info when kernel panic Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2017-09-15 14:10 +0200
Re: [PATCH 3/3] mm: oom: show unreclaimable slab info when kernel panic "Yang Shi" <yang.s@alibaba-inc.com> - 2017-09-15 19:50 +0200
csiph-web