[BUGFIX][PATCH] memcg: force_emtpy fix to confirm cgroup has notasks.

From: KAMEZAWA Hiroyuki
Date: Tue Nov 25 2008 - 04:34:28 EST


This is a fix to memcg-new-force_empty-to-free-pages-under-group.patch

Thanks,
-Kame
==
Now, force_empty can be called and do reclaim pages
while there are tasks. fix it.
(reclaim occurs but move doesn't occur in this case.)

And, we have interface to count # of tasks under cgroup.
Using it is better.

Reported-by: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
mm/memcontrol.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

Index: mmotm-2.6.28-Nov24/mm/memcontrol.c
===================================================================
--- mmotm-2.6.28-Nov24.orig/mm/memcontrol.c
+++ mmotm-2.6.28-Nov24/mm/memcontrol.c
@@ -1481,6 +1481,7 @@ static int mem_cgroup_force_empty(struct
int ret;
int node, zid, shrink;
int nr_retries = MEM_CGROUP_RECLAIM_RETRIES;
+ struct cgroup *cgrp = mem->css.cgroup;

css_get(&mem->css);

@@ -1491,7 +1492,7 @@ static int mem_cgroup_force_empty(struct
move_account:
while (mem->res.usage > 0) {
ret = -EBUSY;
- if (atomic_read(&mem->css.cgroup->count) > 0)
+ if (cgroup_task_count(cgrp) || !list_empty(&cgrp->children))
goto out;
ret = -EINTR;
if (signal_pending(current))
@@ -1523,8 +1524,10 @@ out:
return ret;

try_to_free:
- /* returns EBUSY if we come here twice. */
- if (shrink) {
+ /* returns EBUSY if there is a task or if we come here twice. */
+ if (cgroup_task_count(cgrp)
+ || !list_empty(&cgrp->children)
+ || shrink) {
ret = -EBUSY;
goto out;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/