From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"yamamoto@valinux.co.jp" <yamamoto@valinux.co.jp>,
"xemul@openvz.org" <xemul@openvz.org>,
"lizf@cn.fujitsu.com" <lizf@cn.fujitsu.com>,
"containers@lists.osdl.org" <containers@lists.osdl.org>
Subject: Re: [RFC 1/4] memcg: drop pages at rmdir (v1)
Date: Tue, 27 May 2008 21:41:26 +0530 [thread overview]
Message-ID: <483C32AE.1020908@linux.vnet.ibm.com> (raw)
In-Reply-To: <20080527140533.b4b6f73f.kamezawa.hiroyu@jp.fujitsu.com>
KAMEZAWA Hiroyuki wrote:
> Now, when we remove memcg, we call force_empty().
> This call drops all page_cgroup accounting in this mem_cgroup but doesn't
> drop pages. So, some page caches can be remaind as "not accounted" memory
> while they are alive. (because it's accounted only when add_to_page_cache())
> If they are not used by other memcg, global LRU will drop them.
>
> This patch tries to drop pages at removing memcg. Other memcg will
> reload and re-account page caches. (but this will increase page-in
> after rmdir().)
>
The approach seems fair, but I am not sure about the overhead of flushing out
cached pages. Might well be worth it.
> Consideration: should we recharge all pages to the parent at last ?
> But it's not precise logic.
>
We should look into this - I should send out the multi-hierarchy patches soon.
We should discuss this after that.
> Changelog v1->v2
> - renamed res_counter_empty().
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> ---
> include/linux/res_counter.h | 11 +++++++++++
> mm/memcontrol.c | 19 +++++++++++++++++++
> 2 files changed, 30 insertions(+)
>
> Index: mm-2.6.26-rc2-mm1/mm/memcontrol.c
> ===================================================================
> --- mm-2.6.26-rc2-mm1.orig/mm/memcontrol.c
> +++ mm-2.6.26-rc2-mm1/mm/memcontrol.c
> @@ -791,6 +791,20 @@ int mem_cgroup_shrink_usage(struct mm_st
> return 0;
> }
>
> +
> +static void mem_cgroup_drop_all_pages(struct mem_cgroup *mem)
> +{
> + int progress;
> + while (!res_counter_empty(&mem->res)) {
> + progress = try_to_free_mem_cgroup_pages(mem,
> + GFP_HIGHUSER_MOVABLE);
> + if (!progress) /* we did as much as possible */
> + break;
> + cond_resched();
> + }
> + return;
> +}
> +
> /*
> * This routine traverse page_cgroup in given list and drop them all.
> * *And* this routine doesn't reclaim page itself, just removes page_cgroup.
> @@ -848,7 +862,12 @@ static int mem_cgroup_force_empty(struct
> if (mem_cgroup_subsys.disabled)
> return 0;
>
> + if (atomic_read(&mem->css.cgroup->count) > 0)
> + goto out;
> +
> css_get(&mem->css);
> + /* drop pages as much as possible */
> + mem_cgroup_drop_all_pages(mem);
> /*
> * page reclaim code (kswapd etc..) will move pages between
> * active_list <-> inactive_list while we don't take a lock.
> Index: mm-2.6.26-rc2-mm1/include/linux/res_counter.h
> ===================================================================
> --- mm-2.6.26-rc2-mm1.orig/include/linux/res_counter.h
> +++ mm-2.6.26-rc2-mm1/include/linux/res_counter.h
> @@ -153,4 +153,15 @@ static inline void res_counter_reset_fai
> cnt->failcnt = 0;
> spin_unlock_irqrestore(&cnt->lock, flags);
> }
> +/* returns 0 if usage is 0. */
> +static inline int res_counter_empty(struct res_counter *cnt)
> +{
> + unsigned long flags;
> + int ret;
> +
> + spin_lock_irqsave(&cnt->lock, flags);
> + ret = (cnt->usage == 0) ? 0 : 1;
> + spin_unlock_irqrestore(&cnt->lock, flags);
> + return ret;
> +}
> #endif
>
--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL
--
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-05-27 16:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-27 5:01 [RFC 0/4] memcg: background reclaim (v1) KAMEZAWA Hiroyuki
2008-05-27 5:05 ` [RFC 1/4] memcg: drop pages at rmdir (v1) KAMEZAWA Hiroyuki
2008-05-27 16:11 ` Balbir Singh [this message]
2008-05-28 0:12 ` KAMEZAWA Hiroyuki
2008-05-27 5:07 ` [RFC 2/4] memcg: high-low watermark KAMEZAWA Hiroyuki
2008-05-27 5:30 ` YAMAMOTO Takashi
2008-05-27 7:14 ` KAMEZAWA Hiroyuki
2008-05-27 7:51 ` Li Zefan
2008-05-27 9:42 ` KAMEZAWA Hiroyuki
2008-05-27 16:26 ` Balbir Singh
2008-05-28 0:15 ` KAMEZAWA Hiroyuki
2008-05-27 5:08 ` [RFC 3/4] memcg: background reclaim KAMEZAWA Hiroyuki
2008-05-27 17:08 ` Balbir Singh
2008-05-28 0:45 ` KAMEZAWA Hiroyuki
2008-05-27 5:10 ` [RFC 4/4] memcg: NUMA " KAMEZAWA Hiroyuki
2008-05-27 17:26 ` Balbir Singh
2008-05-28 0:46 ` 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=483C32AE.1020908@linux.vnet.ibm.com \
--to=balbir@linux.vnet.ibm.com \
--cc=containers@lists.osdl.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.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;
as well as URLs for NNTP newsgroup(s).