mm/memcontrol.c: fix the margin computation in mem_cgroup_margin()
[linux-2.6-microblaze.git] / mm / memcontrol.c
index d71d387..485c688 100644 (file)
@@ -1108,6 +1108,8 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg)
                limit = READ_ONCE(memcg->memsw.limit);
                if (count <= limit)
                        margin = min(margin, limit - count);
+               else
+                       margin = 0;
        }
 
        return margin;
@@ -1302,6 +1304,8 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
                                mem_cgroup_iter_break(memcg, iter);
                                if (chosen)
                                        put_task_struct(chosen);
+                               /* Set a dummy value to return "true". */
+                               chosen = (void *) 1;
                                goto unlock;
                        case OOM_SCAN_OK:
                                break;
@@ -1604,7 +1608,7 @@ static void memcg_oom_recover(struct mem_cgroup *memcg)
 
 static void mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order)
 {
-       if (!current->memcg_may_oom)
+       if (!current->memcg_may_oom || current->memcg_in_oom)
                return;
        /*
         * We are in the middle of the charge context here, so we
@@ -2652,8 +2656,7 @@ static inline bool memcg_has_children(struct mem_cgroup *memcg)
 }
 
 /*
- * Reclaims as many pages from the given memcg as possible and moves
- * the rest to the parent.
+ * Reclaims as many pages from the given memcg as possible.
  *
  * Caller is responsible for holding css reference for memcg.
  */