aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/res_counter.h
diff options
context:
space:
mode:
authorBalbir Singh <balbir@linux.vnet.ibm.com>2008-02-07 03:13:56 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:18 -0500
commit66e1707bc34609f626e2e7b4fe7e454c9748bad5 (patch)
treed850a729887485874c976ba64eb85e3406e488a1 /include/linux/res_counter.h
parent67e465a77ba658635309ee00b367bec6555ea544 (diff)
Memory controller: add per cgroup LRU and reclaim
Add the page_cgroup to the per cgroup LRU. The reclaim algorithm has been modified to make the isolate_lru_pages() as a pluggable component. The scan_control data structure now accepts the cgroup on behalf of which reclaims are carried out. try_to_free_pages() has been extended to become cgroup aware. [akpm@linux-foundation.org: fix warning] [Lee.Schermerhorn@hp.com: initialize all scan_control's isolate_pages member] [bunk@kernel.org: make do_try_to_free_pages() static] [hugh@veritas.com: memcgroup: fix try_to_free order] [kamezawa.hiroyu@jp.fujitsu.com: this unlock_page_cgroup() is unnecessary] Signed-off-by: Pavel Emelianov <xemul@openvz.org> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com> Signed-off-by: Hugh Dickins <hugh@veritas.com> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/res_counter.h')
-rw-r--r--include/linux/res_counter.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index eeb3f7749772..5e60a4f34243 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -99,4 +99,27 @@ int res_counter_charge(struct res_counter *counter, unsigned long val);
99void res_counter_uncharge_locked(struct res_counter *counter, unsigned long val); 99void res_counter_uncharge_locked(struct res_counter *counter, unsigned long val);
100void res_counter_uncharge(struct res_counter *counter, unsigned long val); 100void res_counter_uncharge(struct res_counter *counter, unsigned long val);
101 101
102static inline bool res_counter_limit_check_locked(struct res_counter *cnt)
103{
104 if (cnt->usage < cnt->limit)
105 return true;
106
107 return false;
108}
109
110/*
111 * Helper function to detect if the cgroup is within it's limit or
112 * not. It's currently called from cgroup_rss_prepare()
113 */
114static inline bool res_counter_check_under_limit(struct res_counter *cnt)
115{
116 bool ret;
117 unsigned long flags;
118
119 spin_lock_irqsave(&cnt->lock, flags);
120 ret = res_counter_limit_check_locked(cnt);
121 spin_unlock_irqrestore(&cnt->lock, flags);
122 return ret;
123}
124
102#endif 125#endif