提交 ab5196c2 编写于 作者: M Michal Hocko 提交者: Tejun Heo

memcg: make mem_cgroup_reparent_charges non failing

Now that pre_destroy callbacks are called from the context where neither
any task can attach the group nor any children group can be added there
is no other way to fail from mem_cgroup_pre_destroy.
mem_cgroup_pre_destroy doesn't have to take a reference to memcg's css
because all css' are marked dead already.

tj: Remove now unused local variable @cgrp from
    mem_cgroup_reparent_charges().
Signed-off-by: NMichal Hocko <mhocko@suse.cz>
Reviewed-by: NGlauber Costa <glommer@parallels.com>
Acked-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: NTejun Heo <tj@kernel.org>
上级 b25ed609
...@@ -3740,14 +3740,11 @@ static void mem_cgroup_force_empty_list(struct mem_cgroup *memcg, ...@@ -3740,14 +3740,11 @@ static void mem_cgroup_force_empty_list(struct mem_cgroup *memcg,
* *
* Caller is responsible for holding css reference on the memcg. * Caller is responsible for holding css reference on the memcg.
*/ */
static int mem_cgroup_reparent_charges(struct mem_cgroup *memcg) static void mem_cgroup_reparent_charges(struct mem_cgroup *memcg)
{ {
struct cgroup *cgrp = memcg->css.cgroup;
int node, zid; int node, zid;
do { do {
if (cgroup_task_count(cgrp) || !list_empty(&cgrp->children))
return -EBUSY;
/* This is for making all *used* pages to be on LRU. */ /* This is for making all *used* pages to be on LRU. */
lru_add_drain_all(); lru_add_drain_all();
drain_all_stock_sync(memcg); drain_all_stock_sync(memcg);
...@@ -3773,8 +3770,6 @@ static int mem_cgroup_reparent_charges(struct mem_cgroup *memcg) ...@@ -3773,8 +3770,6 @@ static int mem_cgroup_reparent_charges(struct mem_cgroup *memcg)
* charge before adding to the LRU. * charge before adding to the LRU.
*/ */
} while (res_counter_read_u64(&memcg->res, RES_USAGE) > 0); } while (res_counter_read_u64(&memcg->res, RES_USAGE) > 0);
return 0;
} }
/* /*
...@@ -3811,7 +3806,9 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg) ...@@ -3811,7 +3806,9 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg)
} }
lru_add_drain(); lru_add_drain();
return mem_cgroup_reparent_charges(memcg); mem_cgroup_reparent_charges(memcg);
return 0;
} }
static int mem_cgroup_force_empty_write(struct cgroup *cont, unsigned int event) static int mem_cgroup_force_empty_write(struct cgroup *cont, unsigned int event)
...@@ -5008,13 +5005,9 @@ mem_cgroup_create(struct cgroup *cont) ...@@ -5008,13 +5005,9 @@ mem_cgroup_create(struct cgroup *cont)
static int mem_cgroup_pre_destroy(struct cgroup *cont) static int mem_cgroup_pre_destroy(struct cgroup *cont)
{ {
struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
int ret;
css_get(&memcg->css); mem_cgroup_reparent_charges(memcg);
ret = mem_cgroup_reparent_charges(memcg); return 0;
css_put(&memcg->css);
return ret;
} }
static void mem_cgroup_destroy(struct cgroup *cont) static void mem_cgroup_destroy(struct cgroup *cont)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册