From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: balbir@linux.vnet.ibm.com
Cc: linux-mm@kvack.org, YAMAMOTO Takashi <yamamoto@valinux.co.jp>,
Paul Menage <menage@google.com>,
lizf@cn.fujitsu.com, linux-kernel@vger.kernel.org,
Nick Piggin <nickpiggin@yahoo.com.au>,
David Rientjes <rientjes@google.com>,
Pavel Emelianov <xemul@openvz.org>,
Dhaval Giani <dhaval@linux.vnet.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC][mm] [PATCH 3/4] Memory cgroup hierarchical reclaim (v3)
Date: Thu, 13 Nov 2008 13:18:07 +0900 [thread overview]
Message-ID: <20081113131807.b2f22261.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20081112112141.GA25386@balbir.in.ibm.com>
On Wed, 12 Nov 2008 16:51:41 +0530
Balbir Singh <balbir@linux.vnet.ibm.com> wrote:
> Here is the iterative version of this patch. I tested it in my
> test environment. NOTE: The cgroup_locked check is still present, I'll
> remove that shortly after your patch is accepted.
>
> This patch introduces hierarchical reclaim. When an ancestor goes over its
> limit, the charging routine points to the parent that is above its limit.
> The reclaim process then starts from the last scanned child of the ancestor
> and reclaims until the ancestor goes below its limit.
>
complicated as you said but it seems it's from style.
I expected following kind of one.
==
struct mem_cgroup *memcg_select_next_token(struct mem_cgroup *itr,
struct mem_cgroup *cur,
struct mem_cgroup *root)
{
struct cgroup *pos, *tmp, *parent, *rootpos;
cgroup_lock();
if (!itr || itr->obsolete)
itr = cur;
rootpos = root->css.cgroup;
pos = itr->css.cgroup;
parent = pos->parent;
/* start from children */
if (!list_empty(&pos->children)) {
pos = list_entry(pos->children.next, struct cgroup, sibling);
mem_cgroup_put(itr);
itr = mem_cgroup_from_cont(pos);
mem_cgroup_get(itr);
goto unlock;
}
next_parent:
if (pos == rootpos) {
/* I'm root and no available children */
mem_cgroup_put(itr);
itr = mem_cgroup_from_cont(pos);
mem_cgroup_get(itr);
goto unlock;
}
/* Do I have next siblings ? */
if (pos->sibling.next != &parent->children) {
pos = list_entry(pos->sibling.next, struct cgroup, sibling);
mem_cgroup_put(itr);
itr = mem_cgroup_from_cont(pos);
mem_cgroup_get(itr);
goto unlock;
}
/* Ok, go back to parent */
pos = pos->parent;
goto next_parent;
unlock:
root->reclaim_token = token;
cgroup_unlock();
return itr;
}
struct mem_cgroup *memcg_select_start_token(struct mem_cgroup *cur,
struct mem_cgroup *root)
{
struct mem_cgroup *token;
if (cur == root)
return cur;
cgroup_lock();
token = root->reclaim_token;
if (token->obsolete) {
mem_cgroup_put(token); /* decrease refcnt */
root->reclaim_token = cur;
token = cur;
mem_cgroup_get(cur); /* increase refcnt */
cgroup_unlock();
return token;
}
cgroup_unlock();
return memcg_select_next_token(token, cur, root);
}
int mem_cgroup_do_reclaim(struct mem_cgroup *mem,
struct mem_cgroup *root_mem,
gfp_t mask)
{
struct cgroup *cgroup;
struct mem_cgroup *tmp, *token, *start;
/*
* We do memory reclaim under "root_mem".
* We have to be careful not to reclaim memory only from
* unlucky one. For avoiding that, we use "token".
*/
token = memcg_select_start_token(mem, root_mem);
start = NULL;
while (start != token) {
if (!token->obsolete) {
ret = try_to_free_mem_cgroup_pages(token,
GFP_HIGHUSER_MOVABLE);
if (!res_counter_check_under_limit(&root_mem->res))
return 0;
if (ret == 0)
retry--;
start = token;
token = memcg_select_next_token(token, mem, root_mem);
} else {
/* This mem_cgroup is destroyed. */
mem_cgroup_put(token);
token = memcg_select_next_token(NULL, mem, root_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:[~2008-11-13 4:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-11 12:33 [RFC][mm][PATCH 0/4] Memory cgroup hierarchy introduction (v3) Balbir Singh
2008-11-11 12:33 ` [RFC][mm] [PATCH 1/4] Memory cgroup hierarchy documentation (v3) Balbir Singh
2008-11-11 12:34 ` [RFC][mm] [PATCH 2/4] Memory cgroup resource counters for hierarchy (v3) Balbir Singh
2008-11-11 12:34 ` [RFC][mm] [PATCH 3/4] Memory cgroup hierarchical reclaim (v3) Balbir Singh
2008-11-12 3:52 ` KAMEZAWA Hiroyuki
2008-11-12 4:00 ` Balbir Singh
2008-11-12 5:02 ` KAMEZAWA Hiroyuki
2008-11-12 5:49 ` Balbir Singh
2008-11-12 6:01 ` KAMEZAWA Hiroyuki
2008-11-12 6:10 ` Balbir Singh
2008-11-12 6:12 ` KAMEZAWA Hiroyuki
2008-11-12 6:22 ` Balbir Singh
2008-11-12 6:33 ` KAMEZAWA Hiroyuki
2008-11-12 11:21 ` Balbir Singh
2008-11-13 4:18 ` KAMEZAWA Hiroyuki [this message]
2008-11-13 13:33 ` Balbir Singh
2008-11-11 12:34 ` [RFC][mm] [PATCH 4/4] Memory cgroup hierarchy feature selector (v3) Balbir Singh
2008-11-13 1:28 ` Li Zefan
2008-11-13 1:34 ` Balbir Singh
2008-11-13 1:39 ` Li Zefan
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=20081113131807.b2f22261.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=dhaval@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.com \
--cc=nickpiggin@yahoo.com.au \
--cc=rientjes@google.com \
--cc=xemul@openvz.org \
--cc=yamamoto@valinux.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