From: Christopher Lameter <cl@linux.com>
To: Yang Shi <yang.s@alibaba-inc.com>
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
Date: Sun, 1 Oct 2017 01:19:30 -0500 (CDT) [thread overview]
Message-ID: <alpine.DEB.2.20.1710010117410.25658@nuc-kabylake> (raw)
In-Reply-To: <1506548776-67535-3-git-send-email-yang.s@alibaba-inc.com>
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.
next prev parent reply other threads:[~2017-10-01 6:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-27 21:46 [PATCH 0/2 v8] oom: capture unreclaimable slab info in oom message Yang Shi
2017-09-27 21:46 ` [PATCH 1/2] tools: slabinfo: add "-U" option to show unreclaimable slabs only Yang Shi
2017-09-27 21:46 ` [PATCH 2/2] mm: oom: show unreclaimable slab info when unreclaimable slabs > user memory Yang Shi
2017-10-01 6:19 ` Christopher Lameter [this message]
2017-09-28 4:36 ` [PATCH 0/2 v8] oom: capture unreclaimable slab info in oom message Tetsuo Handa
2017-09-28 17:49 ` Yang Shi
2017-09-28 19:57 ` Tetsuo Handa
2017-09-28 20:21 ` Yang Shi
2017-09-28 20:45 ` Tetsuo Handa
2017-09-29 22:15 ` Yang Shi
2017-09-30 11:00 ` Tetsuo Handa
2017-10-02 15:40 ` Yang Shi
2017-10-02 11:20 ` Michal Hocko
2017-10-02 15:46 ` 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.20.1710010117410.25658@nuc-kabylake \
--to=cl@linux.com \
--cc=akpm@linux-foundation.org \
--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=rientjes@google.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox