Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752059AbdISU5U (ORCPT ); Tue, 19 Sep 2017 16:57:20 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:52929 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751710AbdISU5R (ORCPT ); Tue, 19 Sep 2017 16:57:17 -0400 X-Google-Smtp-Source: AOwi7QDbWDdig3CnQ9QruzXx+GEcLgbwWSt01CVaKvNbb3vhOkOTA9/sxNoLb2gZNsELdSpQfssITA== Date: Tue, 19 Sep 2017 13:57:15 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Yang Shi 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 In-Reply-To: <1505759209-102539-3-git-send-email-yang.s@alibaba-inc.com> Message-ID: References: <1505759209-102539-1-git-send-email-yang.s@alibaba-inc.com> <1505759209-102539-3-git-send-email-yang.s@alibaba-inc.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1300 Lines: 44 On Tue, 19 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?