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>
This commit is contained in:
committed by
Linus Torvalds
parent
67e465a77b
commit
66e1707bc3
@@ -32,6 +32,13 @@ extern void page_assign_page_cgroup(struct page *page,
|
||||
extern struct page_cgroup *page_get_page_cgroup(struct page *page);
|
||||
extern int mem_cgroup_charge(struct page *page, struct mm_struct *mm);
|
||||
extern void mem_cgroup_uncharge(struct page_cgroup *pc);
|
||||
extern void mem_cgroup_move_lists(struct page_cgroup *pc, bool active);
|
||||
extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
|
||||
struct list_head *dst,
|
||||
unsigned long *scanned, int order,
|
||||
int mode, struct zone *z,
|
||||
struct mem_cgroup *mem_cont,
|
||||
int active);
|
||||
|
||||
static inline void mem_cgroup_uncharge_page(struct page *page)
|
||||
{
|
||||
@@ -71,6 +78,11 @@ static inline void mem_cgroup_uncharge_page(struct page *page)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void mem_cgroup_move_lists(struct page_cgroup *pc,
|
||||
bool active)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* CONFIG_CGROUP_MEM_CONT */
|
||||
|
||||
#endif /* _LINUX_MEMCONTROL_H */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <linux/linkage.h>
|
||||
#include <linux/mmzone.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/memcontrol.h>
|
||||
#include <linux/sched.h>
|
||||
|
||||
#include <asm/atomic.h>
|
||||
@@ -182,6 +183,8 @@ extern void swap_setup(void);
|
||||
/* linux/mm/vmscan.c */
|
||||
extern unsigned long try_to_free_pages(struct zone **zones, int order,
|
||||
gfp_t gfp_mask);
|
||||
extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem);
|
||||
extern int __isolate_lru_page(struct page *page, int mode);
|
||||
extern unsigned long shrink_all_memory(unsigned long nr_pages);
|
||||
extern int vm_swappiness;
|
||||
extern int remove_mapping(struct address_space *mapping, struct page *page);
|
||||
|
||||
Reference in New Issue
Block a user