[Devel] [PATCH rh7 1/2] mm: memcontrol: add swapin/out stats
Vladimir Davydov
vdavydov at virtuozzo.com
Wed Apr 27 03:32:33 PDT 2016
This patch adds pswpin and pswpout fields to memory.stat file. These
fields show the number of pages swapped in and out respectively for the
given memory cgroup. We assume a page was swapped in/out even if there
were no actual io (frontswap).
https://jira.sw.ru/browse/PSBM-46104
Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
mm/memcontrol.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f617423a3ade..29716f465ffb 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -112,6 +112,8 @@ static const char * const mem_cgroup_stat_names[] = {
enum mem_cgroup_events_index {
MEM_CGROUP_EVENTS_PGPGIN, /* # of pages paged in */
MEM_CGROUP_EVENTS_PGPGOUT, /* # of pages paged out */
+ MEM_CGROUP_EVENTS_PSWPIN, /* # of pages swapped in */
+ MEM_CGROUP_EVENTS_PSWPOUT, /* # of pages swapped out */
MEM_CGROUP_EVENTS_PGFAULT, /* # of page-faults */
MEM_CGROUP_EVENTS_PGMAJFAULT, /* # of major page-faults */
MEM_CGROUP_EVENTS_NSTATS,
@@ -120,6 +122,8 @@ enum mem_cgroup_events_index {
static const char * const mem_cgroup_events_names[] = {
"pgpgin",
"pgpgout",
+ "pswpin",
+ "pswpout",
"pgfault",
"pgmajfault",
};
@@ -3945,6 +3949,8 @@ __mem_cgroup_commit_charge_swapin(struct page *page, struct mem_cgroup *memcg,
swp_entry_t ent = {.val = page_private(page)};
mem_cgroup_uncharge_swap(ent);
}
+
+ this_cpu_inc(memcg->stat->events[MEM_CGROUP_EVENTS_PSWPIN]);
}
void mem_cgroup_commit_charge_swapin(struct page *page,
@@ -4234,6 +4240,9 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
*/
if (do_swap_account && swapout && memcg)
swap_cgroup_record(ent, css_id(&memcg->css));
+
+ if (swapout && memcg)
+ this_cpu_inc(memcg->stat->events[MEM_CGROUP_EVENTS_PSWPOUT]);
}
#endif
--
2.1.4
More information about the Devel
mailing list