From: Michal Hocko <mhocko@suse.cz>
To: linux-mm@kvack.org
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
Tejun Heo <tj@kernel.org>, Li Zefan <lizefan@huawei.com>,
Johannes Weiner <hannes@cmpxchg.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Balbir Singh <bsingharora@gmail.com>
Subject: [PATCH 5/6] memcg: make mem_cgroup_reparent_charges non failing
Date: Wed, 17 Oct 2012 15:30:47 +0200 [thread overview]
Message-ID: <1350480648-10905-6-git-send-email-mhocko@suse.cz> (raw)
In-Reply-To: <1350480648-10905-1-git-send-email-mhocko@suse.cz>
Now that pre_destroy callbacks are called from within cgroup_lock and
the cgroup has been checked to be empty without any children then there
is no other way to fail.
mem_cgroup_pre_destroy doesn't have to take a reference to memcg's css
because all css' are marked dead already.
Signed-off-by: Michal Hocko <mhocko@suse.cz>
---
mm/memcontrol.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f57ba4c..7c75da3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3738,14 +3738,12 @@ static void mem_cgroup_force_empty_list(struct mem_cgroup *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;
do {
- if (cgroup_task_count(cgrp) || !list_empty(&cgrp->children))
- return -EBUSY;
/* This is for making all *used* pages to be on LRU. */
lru_add_drain_all();
drain_all_stock_sync(memcg);
@@ -3771,8 +3769,6 @@ static int mem_cgroup_reparent_charges(struct mem_cgroup *memcg)
* charge before adding to the LRU.
*/
} while (res_counter_read_u64(&memcg->res, RES_USAGE) > 0);
-
- return 0;
}
/*
@@ -3809,7 +3805,9 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg)
}
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)
@@ -5013,13 +5011,9 @@ free_out:
static int mem_cgroup_pre_destroy(struct cgroup *cont)
{
struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
- int ret;
- css_get(&memcg->css);
- ret = mem_cgroup_reparent_charges(memcg);
- css_put(&memcg->css);
-
- return ret;
+ mem_cgroup_reparent_charges(memcg);
+ return 0;
}
static void mem_cgroup_destroy(struct cgroup *cont)
--
1.7.10.4
next prev parent reply other threads:[~2012-10-17 13:31 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-17 13:30 [RFC] memcg/cgroup: do not fail fail on pre_destroy callbacks Michal Hocko
2012-10-17 13:30 ` [PATCH 1/6] memcg: split mem_cgroup_force_empty into reclaiming and reparenting parts Michal Hocko
2012-10-18 21:56 ` Tejun Heo
2012-10-17 13:30 ` [PATCH 2/6] memcg: root_cgroup cannot reach mem_cgroup_move_parent Michal Hocko
2012-10-18 21:58 ` Tejun Heo
2012-10-17 13:30 ` [PATCH 3/6] memcg: Simplify mem_cgroup_force_empty_list error handling Michal Hocko
2012-10-18 22:16 ` Tejun Heo
2012-10-19 13:24 ` Michal Hocko
2012-10-19 19:49 ` Tejun Heo
2012-10-17 13:30 ` [PATCH 4/6] cgroups: forbid pre_destroy callback to fail Michal Hocko
2012-10-18 22:41 ` Tejun Heo
2012-10-18 22:46 ` Tejun Heo
2012-10-19 13:34 ` Michal Hocko
2012-10-19 13:32 ` Michal Hocko
2012-10-19 20:24 ` Tejun Heo
2012-10-22 10:30 ` Michal Hocko
2012-10-24 19:25 ` Tejun Heo
2012-10-25 14:37 ` Michal Hocko
2012-10-25 17:42 ` Tejun Heo
2012-10-25 18:48 ` Michal Hocko
2012-10-19 9:33 ` Li Zefan
2012-10-19 11:09 ` Michal Hocko
2012-10-19 20:17 ` Tejun Heo
2012-10-17 13:30 ` Michal Hocko [this message]
2012-10-18 8:30 ` [PATCH 5/6] memcg: make mem_cgroup_reparent_charges non failing Li Zefan
2012-10-18 8:42 ` Michal Hocko
2012-10-18 22:48 ` Tejun Heo
2012-10-19 13:49 ` Michal Hocko
2012-10-17 13:30 ` [PATCH 6/6] hugetlb: do not fail in hugetlb_cgroup_pre_destroy Michal Hocko
2012-10-18 22:48 ` Tejun Heo
2012-10-17 15:30 ` [RFC] memcg/cgroup: do not fail fail on pre_destroy callbacks Glauber Costa
2012-10-18 0:29 ` 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=1350480648-10905-6-git-send-email-mhocko@suse.cz \
--to=mhocko@suse.cz \
--cc=bsingharora@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan@huawei.com \
--cc=tj@kernel.org \
/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).