From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
"kosaki.motohiro@jp.fujitsu.com" <kosaki.motohiro@jp.fujitsu.com>,
"nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>
Subject: [RFC][PATCH 3/8] trigger for updating soft limit information
Date: Fri, 27 Mar 2009 14:05:28 +0900 [thread overview]
Message-ID: <20090327140528.48c14bce.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20090327135933.789729cb.kamezawa.hiroyu@jp.fujitsu.com>
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Check/Update softlimit information at every charge is over-killing, so
we need some filter.
This patch tries to count events in the memcg and if events > threshold
tries to update memcg's soft limit status and reset event counter to 0.
Both of page-in/out is counted as event.
Event counter is maintained by per-cpu which has been already used,
Then, no siginificant overhead(extra cache-miss etc..) in theory.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
Index: mmotm-2.6.29-Mar23/mm/memcontrol.c
===================================================================
--- mmotm-2.6.29-Mar23.orig/mm/memcontrol.c
+++ mmotm-2.6.29-Mar23/mm/memcontrol.c
@@ -66,6 +66,7 @@ enum mem_cgroup_stat_index {
MEM_CGROUP_STAT_PGPGIN_COUNT, /* # of pages paged in */
MEM_CGROUP_STAT_PGPGOUT_COUNT, /* # of pages paged out */
+ MEM_CGROUP_STAT_EVENTS, /* sum of page-in/page-out for internal use */
MEM_CGROUP_STAT_NSTATS,
};
@@ -105,6 +106,22 @@ static s64 mem_cgroup_local_usage(struct
return ret;
}
+/* For intenal use of per-cpu event counting. */
+
+static inline void
+__mem_cgroup_stat_reset_safe(struct mem_cgroup_stat_cpu *stat,
+ enum mem_cgroup_stat_index idx)
+{
+ stat->count[idx] = 0;
+}
+
+static inline s64
+__mem_cgroup_stat_read_local(struct mem_cgroup_stat_cpu *stat,
+ enum mem_cgroup_stat_index idx)
+{
+ return stat->count[idx];
+}
+
/*
* per-zone information in memory controller.
*/
@@ -235,6 +252,8 @@ static void mem_cgroup_charge_statistics
else
__mem_cgroup_stat_add_safe(cpustat,
MEM_CGROUP_STAT_PGPGOUT_COUNT, 1);
+ __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_EVENTS, 1);
+
put_cpu();
}
@@ -897,9 +916,26 @@ static void record_last_oom(struct mem_c
mem_cgroup_walk_tree(mem, NULL, record_last_oom_cb);
}
+#define SOFTLIMIT_EVENTS_THRESH (1024) /* 1024 times of page-in/out */
+/*
+ * Returns true if sum of page-in/page-out events since last check is
+ * over SOFTLIMIT_EVENT_THRESH. (counter is per-cpu.)
+ */
static bool mem_cgroup_soft_limit_check(struct mem_cgroup *mem)
{
- return false;
+ bool ret = false;
+ int cpu = get_cpu();
+ s64 val;
+ struct mem_cgroup_stat_cpu *cpustat;
+
+ cpustat = &mem->stat.cpustat[cpu];
+ val = __mem_cgroup_stat_read_local(cpustat, MEM_CGROUP_STAT_EVENTS);
+ if (unlikely(val > SOFTLIMIT_EVENTS_THRESH)) {
+ __mem_cgroup_stat_reset_safe(cpustat, MEM_CGROUP_STAT_EVENTS);
+ ret = true;
+ }
+ put_cpu();
+ return ret;
}
static void mem_cgroup_update_soft_limit(struct mem_cgroup *mem)
--
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:[~2009-03-27 4:59 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-27 4:59 [RFC][PATCH] memcg soft limit (yet another new design) v1 KAMEZAWA Hiroyuki
2009-03-27 5:01 ` [RFC][PATCH 1/8] soft limit support in res_counter KAMEZAWA Hiroyuki
2009-03-27 5:03 ` [RFC][PATCH 2/8] soft limit framework in memcg KAMEZAWA Hiroyuki
2009-03-27 8:01 ` KAMEZAWA Hiroyuki
2009-03-29 17:22 ` Balbir Singh
2009-03-27 5:05 ` KAMEZAWA Hiroyuki [this message]
2009-03-27 5:06 ` [RFC][PATCH 4/8] memcg soft limit priority array queue KAMEZAWA Hiroyuki
2009-03-29 16:56 ` Balbir Singh
2009-03-30 23:58 ` KAMEZAWA Hiroyuki
2009-03-27 5:09 ` [RFC][PATCH 5/8] memcg soft limit (yet another new design) v1 KAMEZAWA Hiroyuki
2009-03-27 5:14 ` KAMEZAWA Hiroyuki
2009-03-31 8:18 ` KAMEZAWA Hiroyuki
2009-03-27 5:11 ` [RFC][PATCH 6/8] soft limit victim select KAMEZAWA Hiroyuki
2009-03-27 5:12 ` [RFC][PATCH 7/8] memcg soft limit LRU reorder KAMEZAWA Hiroyuki
2009-03-30 7:52 ` Balbir Singh
2009-03-31 0:00 ` KAMEZAWA Hiroyuki
2009-03-31 6:06 ` Balbir Singh
2009-03-31 6:19 ` KAMEZAWA Hiroyuki
2009-03-27 5:13 ` [RFC][PATCH 8/8] extends soft limit event filter KAMEZAWA Hiroyuki
2009-03-28 8:23 ` [RFC][PATCH] memcg soft limit (yet another new design) v1 Balbir Singh
2009-03-28 16:10 ` KAMEZAWA Hiroyuki
2009-03-28 18:11 ` Balbir Singh
2009-03-28 18:27 ` Balbir Singh
2009-03-30 23:55 ` KAMEZAWA Hiroyuki
2009-03-31 5:00 ` Balbir Singh
2009-03-31 5:05 ` KAMEZAWA Hiroyuki
2009-03-31 5:18 ` KAMEZAWA Hiroyuki
2009-03-31 6:10 ` Balbir Singh
2009-03-31 6:28 ` KAMEZAWA Hiroyuki
2009-03-31 6:49 ` Balbir Singh
2009-03-31 6:56 ` KAMEZAWA Hiroyuki
2009-03-31 6:58 ` KAMEZAWA Hiroyuki
2009-03-31 0:06 ` KAMEZAWA Hiroyuki
2009-03-31 5:01 ` Balbir Singh
2009-03-31 5:11 ` KAMEZAWA Hiroyuki
2009-03-31 6:07 ` Balbir Singh
2009-03-30 23:54 ` KAMEZAWA Hiroyuki
2009-03-29 13:01 ` Balbir Singh
2009-03-30 23:57 ` KAMEZAWA Hiroyuki
2009-04-01 14:42 ` Balbir Singh
2009-04-01 15:11 ` KAMEZAWA Hiroyuki
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=20090327140528.48c14bce.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nishimura@mxp.nes.nec.co.jp \
/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