From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"menage@google.com" <menage@google.com>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
"lizf@cn.fujitsu.com" <lizf@cn.fujitsu.com>,
nishimura@mxp.nes.nec.co.jp
Subject: Re: [PATCH 1/9] fix error path of mem_cgroup_create and refnct handling
Date: Wed, 17 Dec 2008 11:26:08 +0900 [thread overview]
Message-ID: <20081217112608.c2a88905.nishimura@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20081216181041.bbe9bc20.kamezawa.hiroyu@jp.fujitsu.com>
On Tue, 16 Dec 2008 18:10:41 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
>
> From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> 1. Fix double-free BUG in error route of mem_cgroup_create().
> mem_cgroup_free() itself frees per-zone-info.
> 2. Making refcnt of memcg simple.
> Add 1 refcnt at creation and call free when refcnt goes down to 0.
>
I like this change.
> Singed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Thanks,
Daisuke Nishimura.
> ---
> Index: mmotm-2.6.28-Dec15/mm/memcontrol.c
> ===================================================================
> --- mmotm-2.6.28-Dec15.orig/mm/memcontrol.c
> +++ mmotm-2.6.28-Dec15/mm/memcontrol.c
> @@ -2087,14 +2087,10 @@ static struct mem_cgroup *mem_cgroup_all
> * Removal of cgroup itself succeeds regardless of refs from swap.
> */
>
> -static void mem_cgroup_free(struct mem_cgroup *mem)
> +static void __mem_cgroup_free(struct mem_cgroup *mem)
> {
> int node;
>
> - if (atomic_read(&mem->refcnt) > 0)
> - return;
> -
> -
> for_each_node_state(node, N_POSSIBLE)
> free_mem_cgroup_per_zone_info(mem, node);
>
> @@ -2111,11 +2107,8 @@ static void mem_cgroup_get(struct mem_cg
>
> static void mem_cgroup_put(struct mem_cgroup *mem)
> {
> - if (atomic_dec_and_test(&mem->refcnt)) {
> - if (!mem->obsolete)
> - return;
> - mem_cgroup_free(mem);
> - }
> + if (atomic_dec_and_test(&mem->refcnt))
> + __mem_cgroup_free(mem);
> }
>
>
> @@ -2165,12 +2158,10 @@ mem_cgroup_create(struct cgroup_subsys *
>
> if (parent)
> mem->swappiness = get_swappiness(parent);
> -
> + atomic_set(&mem->refcnt, 1);
> return &mem->css;
> free_out:
> - for_each_node_state(node, N_POSSIBLE)
> - free_mem_cgroup_per_zone_info(mem, node);
> - mem_cgroup_free(mem);
> + __mem_cgroup_free(mem);
> return ERR_PTR(-ENOMEM);
> }
>
> @@ -2185,7 +2176,7 @@ static void mem_cgroup_pre_destroy(struc
> static void mem_cgroup_destroy(struct cgroup_subsys *ss,
> struct cgroup *cont)
> {
> - mem_cgroup_free(mem_cgroup_from_cont(cont));
> + mem_cgroup_put(mem_cgroup_from_cont(cont));
> }
>
> static int mem_cgroup_populate(struct cgroup_subsys *ss,
>
--
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-12-17 2:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-16 9:09 [PATCH] memcg updates (2008/12/16) KAMEZAWA Hiroyuki
2008-12-16 9:10 ` [PATCH 1/9] fix error path of mem_cgroup_create and refnct handling KAMEZAWA Hiroyuki
2008-12-17 2:26 ` Daisuke Nishimura [this message]
2008-12-16 9:12 ` [PATCH 2/9] cgroup hierarchy mutex KAMEZAWA Hiroyuki
2008-12-16 9:13 ` [PATCH 3/9] use hierarchy mutex in memcg KAMEZAWA Hiroyuki
2008-12-16 9:14 ` [PATCH 4/9] cgroup add css_tryget() KAMEZAWA Hiroyuki
2008-12-16 9:15 ` [PATCH 5/9] Add css_is_remvoed KAMEZAWA Hiroyuki
2008-12-16 9:17 ` [PATCH 6/9] memcg: use css_tryget() KAMEZAWA Hiroyuki
2008-12-18 1:50 ` Daisuke Nishimura
2008-12-18 2:03 ` KAMEZAWA Hiroyuki
2008-12-16 9:19 ` [PATCH 7/9] cgroup: Support CSS ID KAMEZAWA Hiroyuki
2008-12-16 10:24 ` Paul Menage
2008-12-16 11:09 ` KAMEZAWA Hiroyuki
2008-12-16 9:21 ` [PATCH 8/9] memcg: hierarchical memory reclaim by round-robin KAMEZAWA Hiroyuki
2008-12-16 9:22 ` [PATCH 9/9] memcg : fix OOM killer under hierarchy 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=20081217112608.c2a88905.nishimura@mxp.nes.nec.co.jp \
--to=nishimura@mxp.nes.nec.co.jp \
--cc=balbir@linux.vnet.ibm.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.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