[Devel] [PATCH rh7] proc: meminfo: add tcache pages to MemAvailable

Vladimir Davydov vdavydov at virtuozzo.com
Tue Feb 9 01:42:41 PST 2016


Since they can be easily dropped at any moment, tcache pages should
contribute to MemAvailable.

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

diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index 16960f77027d..8e9077fea885 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -75,6 +75,10 @@ static int meminfo_proc_show_mi(struct seq_file *m, struct meminfo *mi)
 	return 0;
 }
 
+#ifdef CONFIG_TCACHE
+extern unsigned long get_nr_tcache_pages(void);
+#endif
+
 int meminfo_proc_show_ub(struct seq_file *m, void *v,
 		struct user_beancounter *ub, unsigned long meminfo_val)
 {
@@ -148,6 +152,10 @@ int meminfo_proc_show_ub(struct seq_file *m, void *v,
 	available += global_page_state(NR_SLAB_RECLAIMABLE) -
 		     min(global_page_state(NR_SLAB_RECLAIMABLE) / 2, wmark_low);
 
+#ifdef CONFIG_TCACHE
+	available += get_nr_tcache_pages();
+#endif
+
 	if (available < 0)
 		available = 0;
 
diff --git a/mm/tcache.c b/mm/tcache.c
index 9bf756483a78..27fd1872a8d4 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -936,7 +936,7 @@ static struct cleancache_ops tcache_cleancache_ops = {
 	.invalidate_fs		= tcache_cleancache_invalidate_fs,
 };
 
-static int param_get_nr_pages(char *buffer, const struct kernel_param *kp)
+unsigned long get_nr_tcache_pages(void)
 {
 	int cpu;
 	long val = 0;
@@ -945,7 +945,12 @@ static int param_get_nr_pages(char *buffer, const struct kernel_param *kp)
 		val += per_cpu(nr_tcache_pages, cpu);
 	if (val < 0)
 		val = 0;
-	return sprintf(buffer, "%lu", val);
+	return val;
+}
+
+static int param_get_nr_pages(char *buffer, const struct kernel_param *kp)
+{
+	return sprintf(buffer, "%lu", get_nr_tcache_pages());
 }
 
 static struct kernel_param_ops param_ops_nr_pages = {
-- 
2.1.4



More information about the Devel mailing list