Memory controller: make charging gfp mask aware
Nick Piggin pointed out that swap cache and page cache addition routines could be called from non GFP_KERNEL contexts. This patch makes the charging routine aware of the gfp context. Charging might fail if the cgroup is over it's limit, in which case a suitable error is returned. This patch was tested on a Powerpc box. I am still looking at being able to test the path, through which allocations happen in non GFP_KERNEL contexts. [kamezawa.hiroyu@jp.fujitsu.com: problem with ZONE_MOVABLE] Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Pavel Emelianov <xemul@openvz.org> 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: 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
bed7161a51
commit
e1a1cd590e
14
mm/vmscan.c
14
mm/vmscan.c
@@ -1337,16 +1337,11 @@ unsigned long try_to_free_pages(struct zone **zones, int order, gfp_t gfp_mask)
|
||||
|
||||
#ifdef CONFIG_CGROUP_MEM_CONT
|
||||
|
||||
#ifdef CONFIG_HIGHMEM
|
||||
#define ZONE_USERPAGES ZONE_HIGHMEM
|
||||
#else
|
||||
#define ZONE_USERPAGES ZONE_NORMAL
|
||||
#endif
|
||||
|
||||
unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont)
|
||||
unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
|
||||
gfp_t gfp_mask)
|
||||
{
|
||||
struct scan_control sc = {
|
||||
.gfp_mask = GFP_KERNEL,
|
||||
.gfp_mask = gfp_mask,
|
||||
.may_writepage = !laptop_mode,
|
||||
.may_swap = 1,
|
||||
.swap_cluster_max = SWAP_CLUSTER_MAX,
|
||||
@@ -1357,9 +1352,10 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont)
|
||||
};
|
||||
int node;
|
||||
struct zone **zones;
|
||||
int target_zone = gfp_zone(GFP_HIGHUSER_MOVABLE);
|
||||
|
||||
for_each_online_node(node) {
|
||||
zones = NODE_DATA(node)->node_zonelists[ZONE_USERPAGES].zones;
|
||||
zones = NODE_DATA(node)->node_zonelists[target_zone].zones;
|
||||
if (do_try_to_free_pages(zones, sc.gfp_mask, &sc))
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user