aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memory.c
diff options
context:
space:
mode:
authorBalbir Singh <balbir@linux.vnet.ibm.com>2008-02-07 03:14:02 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:19 -0500
commite1a1cd590e3fcb0d2e230128daf2337ea55387dc (patch)
treeeb660ab340c657a1eb595b2d4d8e8b62783bf6fb /mm/memory.c
parentbed7161a519a2faef53e1bce1b47595e297c1d14 (diff)
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>
Diffstat (limited to 'mm/memory.c')
-rw-r--r--mm/memory.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mm/memory.c b/mm/memory.c
index 0ba224ea6ba4..153a54b2013c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1147,7 +1147,7 @@ static int insert_page(struct mm_struct *mm, unsigned long addr, struct page *pa
1147 pte_t *pte; 1147 pte_t *pte;
1148 spinlock_t *ptl; 1148 spinlock_t *ptl;
1149 1149
1150 retval = mem_cgroup_charge(page, mm); 1150 retval = mem_cgroup_charge(page, mm, GFP_KERNEL);
1151 if (retval) 1151 if (retval)
1152 goto out; 1152 goto out;
1153 1153
@@ -1650,7 +1650,7 @@ gotten:
1650 cow_user_page(new_page, old_page, address, vma); 1650 cow_user_page(new_page, old_page, address, vma);
1651 __SetPageUptodate(new_page); 1651 __SetPageUptodate(new_page);
1652 1652
1653 if (mem_cgroup_charge(new_page, mm)) 1653 if (mem_cgroup_charge(new_page, mm, GFP_KERNEL))
1654 goto oom_free_new; 1654 goto oom_free_new;
1655 1655
1656 /* 1656 /*
@@ -2052,7 +2052,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
2052 count_vm_event(PGMAJFAULT); 2052 count_vm_event(PGMAJFAULT);
2053 } 2053 }
2054 2054
2055 if (mem_cgroup_charge(page, mm)) { 2055 if (mem_cgroup_charge(page, mm, GFP_KERNEL)) {
2056 delayacct_clear_flag(DELAYACCT_PF_SWAPIN); 2056 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
2057 ret = VM_FAULT_OOM; 2057 ret = VM_FAULT_OOM;
2058 goto out; 2058 goto out;
@@ -2139,7 +2139,7 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
2139 goto oom; 2139 goto oom;
2140 __SetPageUptodate(page); 2140 __SetPageUptodate(page);
2141 2141
2142 if (mem_cgroup_charge(page, mm)) 2142 if (mem_cgroup_charge(page, mm, GFP_KERNEL))
2143 goto oom_free_page; 2143 goto oom_free_page;
2144 2144
2145 entry = mk_pte(page, vma->vm_page_prot); 2145 entry = mk_pte(page, vma->vm_page_prot);
@@ -2277,7 +2277,7 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
2277 2277
2278 } 2278 }
2279 2279
2280 if (mem_cgroup_charge(page, mm)) { 2280 if (mem_cgroup_charge(page, mm, GFP_KERNEL)) {
2281 ret = VM_FAULT_OOM; 2281 ret = VM_FAULT_OOM;
2282 goto out; 2282 goto out;
2283 } 2283 }