oom: badness heuristic rewrite
[pandora-kernel.git] / mm / memcontrol.c
index 20a8193..de54ea0 100644 (file)
@@ -211,8 +211,6 @@ struct mem_cgroup {
        */
        spinlock_t reclaim_param_lock;
 
-       int     prev_priority;  /* for recording reclaim priority */
-
        /*
         * While reclaiming in a hierarchy, we cache the last child we
         * reclaimed from.
@@ -858,35 +856,6 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem)
        return ret;
 }
 
-/*
- * prev_priority control...this will be used in memory reclaim path.
- */
-int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem)
-{
-       int prev_priority;
-
-       spin_lock(&mem->reclaim_param_lock);
-       prev_priority = mem->prev_priority;
-       spin_unlock(&mem->reclaim_param_lock);
-
-       return prev_priority;
-}
-
-void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem, int priority)
-{
-       spin_lock(&mem->reclaim_param_lock);
-       if (priority < mem->prev_priority)
-               mem->prev_priority = priority;
-       spin_unlock(&mem->reclaim_param_lock);
-}
-
-void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, int priority)
-{
-       spin_lock(&mem->reclaim_param_lock);
-       mem->prev_priority = priority;
-       spin_unlock(&mem->reclaim_param_lock);
-}
-
 static int calc_inactive_ratio(struct mem_cgroup *memcg, unsigned long *present_pages)
 {
        unsigned long active;
@@ -1157,6 +1126,24 @@ static int mem_cgroup_count_children(struct mem_cgroup *mem)
        return num;
 }
 
+/*
+ * Return the memory (and swap, if configured) limit for a memcg.
+ */
+u64 mem_cgroup_get_limit(struct mem_cgroup *memcg)
+{
+       u64 limit;
+       u64 memsw;
+
+       limit = res_counter_read_u64(&memcg->res, RES_LIMIT) +
+                       total_swap_pages;
+       memsw = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
+       /*
+        * If memsw is finite and limits the amount of swap space available
+        * to this memcg, return that limit.
+        */
+       return min(limit, memsw);
+}
+
 /*
  * Visit the first child (need not be the first child as per the ordering
  * of the cgroup list, since we track last_scanned_child) of @mem and use