From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Rik van Riel <riel@redhat.com>,
Minchan Kim <minchan.kim@gmail.com>
Cc: kosaki.motohiro@jp.fujitsu.com
Subject: [PATCH 3/3] [v2] memcg: add anon_scan_ratio to memory.stat file
Date: Wed, 13 Jan 2010 17:22:37 +0900 (JST) [thread overview]
Message-ID: <20100113172143.B3E8.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <20100113171734.B3E2.A69D9226@jp.fujitsu.com>
Changelog
since v1: cancel to remove "recent_xxx" debug statistics as bilbir's
mention
===========================================
anon_scan_ratio feature doesn't only useful for global VM pressure
analysis, but it also useful for memcg memroy pressure analysis.
Then, this patch add anon_scan_ratio field to memory.stat file too.
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
mm/memcontrol.c | 65 +++++++++++++++++++++++++++++++++++-------------------
1 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 325df12..7348edc 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2950,6 +2950,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
{
struct mem_cgroup *mem_cont = mem_cgroup_from_cont(cont);
struct mcs_total_stat mystat;
+ struct zone *zone;
+ unsigned long total_anon = 0;
+ unsigned long total_scan_anon = 0;
+ unsigned long recent_rotated[2] = {0};
+ unsigned long recent_scanned[2] = {0};
int i;
memset(&mystat, 0, sizeof(mystat));
@@ -2978,33 +2983,47 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
}
-#ifdef CONFIG_DEBUG_VM
cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL));
- {
- int nid, zid;
+ for_each_populated_zone(zone) {
+ int nid = zone->zone_pgdat->node_id;
+ int zid = zone_idx(zone);
struct mem_cgroup_per_zone *mz;
- unsigned long recent_rotated[2] = {0, 0};
- unsigned long recent_scanned[2] = {0, 0};
-
- for_each_online_node(nid)
- for (zid = 0; zid < MAX_NR_ZONES; zid++) {
- mz = mem_cgroup_zoneinfo(mem_cont, nid, zid);
-
- recent_rotated[0] +=
- mz->reclaim_stat.recent_rotated[0];
- recent_rotated[1] +=
- mz->reclaim_stat.recent_rotated[1];
- recent_scanned[0] +=
- mz->reclaim_stat.recent_scanned[0];
- recent_scanned[1] +=
- mz->reclaim_stat.recent_scanned[1];
- }
- cb->fill(cb, "recent_rotated_anon", recent_rotated[0]);
- cb->fill(cb, "recent_rotated_file", recent_rotated[1]);
- cb->fill(cb, "recent_scanned_anon", recent_scanned[0]);
- cb->fill(cb, "recent_scanned_file", recent_scanned[1]);
+ unsigned long anon;
+ unsigned long ratio;
+
+ mz = mem_cgroup_zoneinfo(mem_cont, nid, zid);
+
+ anon = MEM_CGROUP_ZSTAT(mz, LRU_INACTIVE_ANON);
+ anon += MEM_CGROUP_ZSTAT(mz, LRU_ACTIVE_ANON);
+
+ ratio = get_anon_scan_ratio(zone, mem_cont, mem_cont->swappiness);
+
+ /*
+ * We have per-zone anon-scan-ratio. but we don't hope display such
+ * value directly. Instead, we display following fomula.
+ *
+ * sum(anon * ratio/100)
+ * --------------------- * 100
+ * sum(anon)
+ */
+ total_anon += anon;
+ total_scan_anon += anon * ratio;
+
+#ifdef CONFIG_DEBUG_VM
+ recent_rotated[0] += mz->reclaim_stat.recent_rotated[0];
+ recent_rotated[1] += mz->reclaim_stat.recent_rotated[1];
+ recent_scanned[0] += mz->reclaim_stat.recent_scanned[0];
+ recent_scanned[1] += mz->reclaim_stat.recent_scanned[1];
+#endif
}
+ cb->fill(cb, "anon_scan_ratio", total_scan_anon / total_anon);
+
+#ifdef CONFIG_DEBUG_VM
+ cb->fill(cb, "recent_rotated_anon", recent_rotated[0]);
+ cb->fill(cb, "recent_rotated_file", recent_rotated[1]);
+ cb->fill(cb, "recent_scanned_anon", recent_scanned[0]);
+ cb->fill(cb, "recent_scanned_file", recent_scanned[1]);
#endif
return 0;
--
1.6.5.2
--
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>
next prev parent reply other threads:[~2010-01-13 8:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-13 8:19 [PATCH 1/3] vmscan: get_scan_ratio cleanup KOSAKI Motohiro
2010-01-13 8:21 ` [PATCH 2/3][v2] vmstat: add anon_scan_ratio field to zoneinfo KOSAKI Motohiro
2010-01-13 10:31 ` Minchan Kim
2010-01-13 23:50 ` KOSAKI Motohiro
2010-01-14 5:12 ` Minchan Kim
2010-01-14 5:18 ` KOSAKI Motohiro
2010-01-15 17:23 ` Minchan Kim
2010-01-18 1:04 ` KOSAKI Motohiro
2010-01-18 1:47 ` Minchan Kim
2010-01-18 1:54 ` KOSAKI Motohiro
2010-01-18 2:10 ` Minchan Kim
2010-01-18 2:14 ` KOSAKI Motohiro
2010-01-18 2:16 ` Rik van Riel
2010-01-18 2:24 ` KOSAKI Motohiro
2010-01-18 2:25 ` Minchan Kim
2010-01-13 8:22 ` KOSAKI Motohiro [this message]
2010-01-13 8:24 ` [PATCH 3/3] [v2] memcg: add anon_scan_ratio to memory.stat file KAMEZAWA Hiroyuki
2010-01-13 9:08 ` Balbir Singh
2010-01-13 9:54 ` [PATCH 1/3] vmscan: get_scan_ratio cleanup Minchan Kim
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=20100113172143.B3E8.A69D9226@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan.kim@gmail.com \
--cc=riel@redhat.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