linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Yang Shi" <yang.s@alibaba-inc.com>
To: cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org
Cc: Yang Shi <yang.s@alibaba-inc.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] mm: slab: output reclaimable flag in /proc/slabinfo
Date: Fri, 15 Sep 2017 01:14:47 +0800	[thread overview]
Message-ID: <1505409289-57031-2-git-send-email-yang.s@alibaba-inc.com> (raw)
In-Reply-To: <1505409289-57031-1-git-send-email-yang.s@alibaba-inc.com>

Although slabinfo in tools can print out the flag of slabs to show which
one is reclaimable, it sounds nice to have reclaimable flag shows in
/proc/slabinfo too since /proc should be still the first place to check
those slab info.

Add a new column called "reclaim" in /proc/slabinfo, "1" means
reclaimable, "0" means unreclaimable.

Signed-off-by: Yang Shi <yang.s@alibaba-inc.com>
---
 mm/slab.c        | 1 +
 mm/slab.h        | 6 ++++++
 mm/slab_common.c | 2 ++
 mm/slub.c        | 1 +
 4 files changed, 10 insertions(+)

diff --git a/mm/slab.c b/mm/slab.c
index 04dec48..4f4971c 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4132,6 +4132,7 @@ void get_slabinfo(struct kmem_cache *cachep, struct slabinfo *sinfo)
 	sinfo->shared = cachep->shared;
 	sinfo->objects_per_slab = cachep->num;
 	sinfo->cache_order = cachep->gfporder;
+	sinfo->reclaim = is_reclaimable(cachep);
 }
 
 void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
diff --git a/mm/slab.h b/mm/slab.h
index 0733628..cf01a6e 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -186,6 +186,7 @@ struct slabinfo {
 	unsigned int shared;
 	unsigned int objects_per_slab;
 	unsigned int cache_order;
+	unsigned int reclaim;
 };
 
 void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo);
@@ -352,6 +353,11 @@ static inline void memcg_link_cache(struct kmem_cache *s)
 
 #endif /* CONFIG_MEMCG && !CONFIG_SLOB */
 
+static inline bool is_reclaimable(struct kmem_cache *s)
+{
+	return (s->flags & SLAB_RECLAIM_ACCOUNT) ? true : false;
+}
+
 static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
 {
 	struct kmem_cache *cachep;
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 904a83b..8a55730 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -1201,6 +1201,7 @@ static void print_slabinfo_header(struct seq_file *m)
 	seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> <error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
 	seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
 #endif
+	seq_puts(m, " : reclaim");
 	seq_putc(m, '\n');
 }
 
@@ -1259,6 +1260,7 @@ static void cache_show(struct kmem_cache *s, struct seq_file *m)
 	seq_printf(m, " : slabdata %6lu %6lu %6lu",
 		   sinfo.active_slabs, sinfo.num_slabs, sinfo.shared_avail);
 	slabinfo_show_stats(m, s);
+	seq_printf(m, " : %u", sinfo.reclaim);
 	seq_putc(m, '\n');
 }
 
diff --git a/mm/slub.c b/mm/slub.c
index d39a5d3..c8526c0 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5872,6 +5872,7 @@ void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo)
 	sinfo->num_slabs = nr_slabs;
 	sinfo->objects_per_slab = oo_objects(s->oo);
 	sinfo->cache_order = oo_order(s->oo);
+	sinfo->reclaim = is_reclaimable(s);
 }
 
 void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *s)
-- 
1.8.3.1

--
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-14 17:15 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 when kernel panic Yang Shi
2017-09-14 17:14 ` Yang Shi [this message]
2017-09-14 17:27   ` [PATCH 1/3] mm: slab: output reclaimable flag in /proc/slabinfo 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

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=1505409289-57031-2-git-send-email-yang.s@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=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