[Devel] [PATCH rh7] meminfo: show size of tcache and tswap

Vladimir Davydov vdavydov at virtuozzo.com
Wed Apr 27 03:26:47 PDT 2016


Although these counters are already available via
/sys/module/{tcache,tswap}/parameters/nr_pages, having them in
/proc/meminfo will come handy, e.g. because meminfo is already
gathered by perf tests, while those counters are not.

Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 fs/proc/meminfo.c | 15 +++++++++++++++
 mm/tswap.c        |  5 +++++
 2 files changed, 20 insertions(+)

diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index 8e9077fea885..40db369116b4 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -78,6 +78,9 @@ static int meminfo_proc_show_mi(struct seq_file *m, struct meminfo *mi)
 #ifdef CONFIG_TCACHE
 extern unsigned long get_nr_tcache_pages(void);
 #endif
+#ifdef CONFIG_TSWAP
+extern unsigned long get_nr_tswap_pages(void);
+#endif
 
 int meminfo_proc_show_ub(struct seq_file *m, void *v,
 		struct user_beancounter *ub, unsigned long meminfo_val)
@@ -215,6 +218,12 @@ int meminfo_proc_show_ub(struct seq_file *m, void *v,
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 		"AnonHugePages:  %8lu kB\n"
 #endif
+#ifdef CONFIG_TCACHE
+		"Tcache:         %8lu kB\n"
+#endif
+#ifdef CONFIG_TSWAP
+		"Tswap:          %8lu kB\n"
+#endif
 		,
 		K(i.totalram),
 		K(i.freeram),
@@ -276,6 +285,12 @@ int meminfo_proc_show_ub(struct seq_file *m, void *v,
 		,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
 		   HPAGE_PMD_NR)
 #endif
+#ifdef CONFIG_TCACHE
+		,K(get_nr_tcache_pages())
+#endif
+#ifdef CONFIG_TSWAP
+		,K(get_nr_tswap_pages())
+#endif
 		);
 
 	hugetlb_report_meminfo(m);
diff --git a/mm/tswap.c b/mm/tswap.c
index 20c952b4716c..258728519364 100644
--- a/mm/tswap.c
+++ b/mm/tswap.c
@@ -38,6 +38,11 @@ module_param_named(active, tswap_active, bool, 0644);
 static unsigned long tswap_nr_pages;
 module_param_named(nr_pages, tswap_nr_pages, ulong, 0444);
 
+unsigned long get_nr_tswap_pages(void)
+{
+	return tswap_nr_pages;
+}
+
 static void tswap_lru_add(struct page *page)
 {
 	struct tswap_lru *lru = &tswap_lru_node[page_to_nid(page)];
-- 
2.1.4



More information about the Devel mailing list