From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751010AbdJAGTf (ORCPT ); Sun, 1 Oct 2017 02:19:35 -0400 Received: from resqmta-po-06v.sys.comcast.net ([96.114.154.165]:47180 "EHLO resqmta-po-06v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750911AbdJAGTd (ORCPT ); Sun, 1 Oct 2017 02:19:33 -0400 Date: Sun, 1 Oct 2017 01:19:30 -0500 (CDT) From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Yang Shi cc: penberg@kernel.org, rientjes@google.com, 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 unreclaimable slabs > user memory In-Reply-To: <1506548776-67535-3-git-send-email-yang.s@alibaba-inc.com> Message-ID: References: <1506548776-67535-1-git-send-email-yang.s@alibaba-inc.com> <1506548776-67535-3-git-send-email-yang.s@alibaba-inc.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CMAE-Envelope: MS4wfPsP8mwz800o8hJXKPEvzBz9utfdsGUCuMbZbll2SzEASe+98u+yzx+0Tant6t+2CT4eiN08SnB7pSo6FAHAPI00eX3zsC4lLgzFk1L+yIH6phMyHhqg 5a5f1wINa9KK8I/MdimLoQgebMcqo7zLnH22PYPBQWjvcxXDbSUPvoozscYVAZNJenX+xSu9KZx0tz6z0SnmG4Ahb3dW1UQL9W5f6qgOp8p1WCzhcJU5OVKC 9PkBUbib2xLKbXxp03KVvKkirz4phz3ttWhJr9k3bZU7wTlq2bfI6Oz4FgGd6LSdse4L8Voa0H0Ge0TGukXk3ea7FA8FG5YAgcZrxo2N4vQ1ZjxV6fo77p7P HgS4qUCuR4K8+zETMkvXqVYK2SKaMtWFffSyHCUTkJgxt+DiICU= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 28 Sep 2017, Yang Shi wrote: > diff --git a/mm/slab.h b/mm/slab.h > index 0733628..b0496d1 100644 > --- a/mm/slab.h > +++ b/mm/slab.h > @@ -505,6 +505,14 @@ static inline struct kmem_cache_node *get_node(struct kmem_cache *s, int node) > void memcg_slab_stop(struct seq_file *m, void *p); > int memcg_slab_show(struct seq_file *m, void *p); > > +#ifdef CONFIG_SLABINFO > +void dump_unreclaimable_slab(void); > +#else > +static inline void dump_unreclaimable_slab(void) > +{ > +} > +#endif > + > void ___cache_free(struct kmem_cache *cache, void *x, unsigned long addr); > > #ifdef CONFIG_SLAB_FREELIST_RANDOM > diff --git a/mm/slab_common.c b/mm/slab_common.c > index 904a83b..d08213d 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -1272,6 +1272,35 @@ static int slab_show(struct seq_file *m, void *p) > return 0; > } > > +void dump_unreclaimable_slab(void) > +{ > + struct kmem_cache *s, *s2; > + struct slabinfo sinfo; > + > + pr_info("Unreclaimable slab info:\n"); > + pr_info("Name Used Total\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_safe(s, s2, &slab_caches, list) { > + if (!is_root_cache(s) || (s->flags & SLAB_RECLAIM_ACCOUNT)) > + continue; > + > + memset(&sinfo, 0, sizeof(sinfo)); > + get_slabinfo(s, &sinfo); > + > + if (sinfo.num_objs > 0) > + pr_info("%-17s %10luKB %10luKB\n", cache_name(s), > + (sinfo.active_objs * s->size) / 1024, > + (sinfo.num_objs * s->size) / 1024); > + } > +} > + > #if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB) > void *memcg_slab_start(struct seq_file *m, loff_t *pos) > { > SLABINFO is a legacy feature abd dump_unreclaimable_slab is definitely not. It also does not depend on /proc/slabinfo support. Please move the code out of the #ifdef CONFIG_SLABINFO section.