]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/res_counter.h
Memory controller: add per cgroup LRU and reclaim
[linux-2.6-omap-h63xx.git] / include / linux / res_counter.h
index eeb3f7749772d3b0b3166893d275ee7ef78b40bb..5e60a4f342432559a93c8b9207451abb190012c1 100644 (file)
@@ -99,4 +99,27 @@ int res_counter_charge(struct res_counter *counter, unsigned long val);
 void res_counter_uncharge_locked(struct res_counter *counter, unsigned long val);
 void res_counter_uncharge(struct res_counter *counter, unsigned long val);
 
+static inline bool res_counter_limit_check_locked(struct res_counter *cnt)
+{
+       if (cnt->usage < cnt->limit)
+               return true;
+
+       return false;
+}
+
+/*
+ * Helper function to detect if the cgroup is within it's limit or
+ * not. It's currently called from cgroup_rss_prepare()
+ */
+static inline bool res_counter_check_under_limit(struct res_counter *cnt)
+{
+       bool ret;
+       unsigned long flags;
+
+       spin_lock_irqsave(&cnt->lock, flags);
+       ret = res_counter_limit_check_locked(cnt);
+       spin_unlock_irqrestore(&cnt->lock, flags);
+       return ret;
+}
+
 #endif