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 2/8] soft limit framework in memcg.
Date: Fri, 27 Mar 2009 14:03:46 +0900 [thread overview]
Message-ID: <20090327140346.8d27b69a.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20090327135933.789729cb.kamezawa.hiroyu@jp.fujitsu.com>
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Add minimal modification for soft limit to res_counter_charge() and memcontol.c
Based on Balbir Singh <balbir@linux.vnet.ibm.com> 's work but most of
features are removed. (dropped or moved to later patch.)
This is for building a frame to implement soft limit handler in memcg.
- Checks soft limit status at every charge.
- Adds mem_cgroup_soft_limit_check() as a function to detect we need
check now or not.
- mem_cgroup_update_soft_limit() is a function for updates internal status
of soft limit controller of memcg.
- This has no hooks in uncharge path. (see later patch.)
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
Index: mmotm-2.6.29-Mar23/include/linux/res_counter.h
===================================================================
--- mmotm-2.6.29-Mar23.orig/include/linux/res_counter.h
+++ mmotm-2.6.29-Mar23/include/linux/res_counter.h
@@ -112,7 +112,8 @@ void res_counter_init(struct res_counter
int __must_check res_counter_charge_locked(struct res_counter *counter,
unsigned long val);
int __must_check res_counter_charge(struct res_counter *counter,
- unsigned long val, struct res_counter **limit_fail_at);
+ unsigned long val, struct res_counter **limit_fail_at,
+ bool *soft_limit_failure);
/*
* uncharge - tell that some portion of the resource is released
Index: mmotm-2.6.29-Mar23/kernel/res_counter.c
===================================================================
--- mmotm-2.6.29-Mar23.orig/kernel/res_counter.c
+++ mmotm-2.6.29-Mar23/kernel/res_counter.c
@@ -37,9 +37,11 @@ int res_counter_charge_locked(struct res
}
int res_counter_charge(struct res_counter *counter, unsigned long val,
- struct res_counter **limit_fail_at)
+ struct res_counter **limit_fail_at,
+ bool *soft_limit_failure)
{
int ret;
+ int soft_cnt = 0;
unsigned long flags;
struct res_counter *c, *u;
@@ -48,6 +50,8 @@ int res_counter_charge(struct res_counte
for (c = counter; c != NULL; c = c->parent) {
spin_lock(&c->lock);
ret = res_counter_charge_locked(c, val);
+ if (!res_counter_soft_limit_check_locked(c))
+ soft_cnt += 1;
spin_unlock(&c->lock);
if (ret < 0) {
*limit_fail_at = c;
@@ -55,6 +59,12 @@ int res_counter_charge(struct res_counte
}
}
ret = 0;
+ if (soft_limit_failure) {
+ if (!soft_cnt)
+ *soft_limit_failure = false;
+ else
+ *soft_limit_failure = true;
+ }
goto done;
undo:
for (u = counter; u != c; u = u->parent) {
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
@@ -897,6 +897,15 @@ static void record_last_oom(struct mem_c
mem_cgroup_walk_tree(mem, NULL, record_last_oom_cb);
}
+static bool mem_cgroup_soft_limit_check(struct mem_cgroup *mem)
+{
+ return false;
+}
+
+static void mem_cgroup_update_soft_limit(struct mem_cgroup *mem)
+{
+ return;
+}
/*
* Unlike exported interface, "oom" parameter is added. if oom==true,
@@ -909,6 +918,7 @@ static int __mem_cgroup_try_charge(struc
struct mem_cgroup *mem, *mem_over_limit;
int nr_retries = MEM_CGROUP_RECLAIM_RETRIES;
struct res_counter *fail_res;
+ bool soft_fail;
if (unlikely(test_thread_flag(TIF_MEMDIE))) {
/* Don't account this! */
@@ -938,12 +948,13 @@ static int __mem_cgroup_try_charge(struc
int ret;
bool noswap = false;
- ret = res_counter_charge(&mem->res, PAGE_SIZE, &fail_res);
+ ret = res_counter_charge(&mem->res, PAGE_SIZE, &fail_res,
+ &soft_fail);
if (likely(!ret)) {
if (!do_swap_account)
break;
ret = res_counter_charge(&mem->memsw, PAGE_SIZE,
- &fail_res);
+ &fail_res, NULL);
if (likely(!ret))
break;
/* mem+swap counter fails */
@@ -985,6 +996,10 @@ static int __mem_cgroup_try_charge(struc
goto nomem;
}
}
+
+ if (soft_fail && mem_cgroup_soft_limit_check(mem))
+ mem_cgroup_update_soft_limit(mem);
+
return 0;
nomem:
css_put(&mem->css);
@@ -2409,6 +2424,7 @@ static void __mem_cgroup_free(struct mem
{
int node;
+ mem_cgroup_update_soft_limit(mem);
free_css_id(&mem_cgroup_subsys, &mem->css);
for_each_node_state(node, N_POSSIBLE)
--
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:58 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 ` KAMEZAWA Hiroyuki [this message]
2009-03-27 8:01 ` [RFC][PATCH 2/8] soft limit framework in memcg KAMEZAWA Hiroyuki
2009-03-29 17:22 ` Balbir Singh
2009-03-27 5:05 ` [RFC][PATCH 3/8] trigger for updating soft limit information KAMEZAWA Hiroyuki
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=20090327140346.8d27b69a.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