[Devel] [PATCH rh7 2/2] ub: show swapin/out in /proc/bc/<bc>/vmaux

Vladimir Davydov vdavydov at virtuozzo.com
Wed Apr 27 03:32:34 PDT 2016


Required for backward compatibility. The values are received from the
associated memory cgroup.

https://jira.sw.ru/browse/PSBM-46104

Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 include/bc/beancounter.h | 3 +++
 kernel/bc/vm_pages.c     | 3 +++
 mm/memcontrol.c          | 8 ++++++++
 3 files changed, 14 insertions(+)

diff --git a/include/bc/beancounter.h b/include/bc/beancounter.h
index d004afa5be3c..8316cc4861a3 100644
--- a/include/bc/beancounter.h
+++ b/include/bc/beancounter.h
@@ -105,6 +105,9 @@ struct user_beancounter {
 	atomic_long_t		wb_requests;
 	atomic_long_t		wb_sectors;
 
+	unsigned long		swapin;
+	unsigned long		swapout;
+
 	void			*iolimit;
 
 	/* resources statistic and settings */
diff --git a/kernel/bc/vm_pages.c b/kernel/bc/vm_pages.c
index 7529899538a9..b46da98fece2 100644
--- a/kernel/bc/vm_pages.c
+++ b/kernel/bc/vm_pages.c
@@ -253,6 +253,9 @@ static int bc_vmaux_show(struct seq_file *f, void *v)
 
 	ub_sync_memcg(ub);
 
+	seq_printf(f, bc_proc_lu_fmt, "swapin", ub->swapin);
+	seq_printf(f, bc_proc_lu_fmt, "swapout", ub->swapout);
+
 	seq_printf(f, bc_proc_lu_fmt, "ram", ub->ub_parms[UB_PHYSPAGES].held);
 
 	return 0;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 29716f465ffb..61c395b7c4ed 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5440,6 +5440,7 @@ static int mem_cgroup_move_charge_write(struct cgroup *cgrp,
 void mem_cgroup_sync_beancounter(struct mem_cgroup *memcg,
 				 struct user_beancounter *ub)
 {
+	struct mem_cgroup *mi;
 	unsigned long long lim, held, maxheld;
 	volatile struct ubparm *k, *d, *p, *s, *o;
 
@@ -5493,6 +5494,13 @@ void mem_cgroup_sync_beancounter(struct mem_cgroup *memcg,
 	lim = lim >= RESOURCE_MAX ? UB_MAXVALUE :
 		min_t(unsigned long long, lim >> PAGE_SHIFT, UB_MAXVALUE);
 	o->barrier = o->limit = lim;
+
+	ub->swapin = 0;
+	ub->swapout = 0;
+	for_each_mem_cgroup_tree(mi, memcg) {
+		ub->swapin += mem_cgroup_read_events(mi, MEM_CGROUP_EVENTS_PSWPIN);
+		ub->swapout += mem_cgroup_read_events(mi, MEM_CGROUP_EVENTS_PSWPOUT);
+	}
 }
 
 int mem_cgroup_apply_beancounter(struct mem_cgroup *memcg,
-- 
2.1.4



More information about the Devel mailing list