aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorHugh Dickins <hugh.dickins@tiscali.co.uk>2009-09-21 20:03:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-22 10:17:40 -0400
commit1ac0cb5d0e22d5e483f56b2bc12172dec1cf7536 (patch)
tree68114711dc747a557895896af991623438034c2d /mm
parent2a15efc953b26ad57d7d38b9e6782d57e53b4ab2 (diff)
mm: fix anonymous dirtying
do_anonymous_page() has been wrong to dirty the pte regardless. If it's not going to mark the pte writable, then it won't help to mark it dirty here, and clogs up memory with pages which will need swap instead of being thrown away. Especially wrong if no overcommit is chosen, and this vma is not yet VM_ACCOUNTed - we could exceed the limit and OOM despite no overcommit. Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk> Cc: <stable@kernel.org> Acked-by: Rik van Riel <riel@redhat.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Nick Piggin <npiggin@suse.de> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Minchan Kim <minchan.kim@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memory.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/memory.c b/mm/memory.c
index 6359a4f80c4a..fc38d4ed9ad9 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2653,7 +2653,8 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
2653 goto oom_free_page; 2653 goto oom_free_page;
2654 2654
2655 entry = mk_pte(page, vma->vm_page_prot); 2655 entry = mk_pte(page, vma->vm_page_prot);
2656 entry = maybe_mkwrite(pte_mkdirty(entry), vma); 2656 if (vma->vm_flags & VM_WRITE)
2657 entry = pte_mkwrite(pte_mkdirty(entry));
2657 2658
2658 page_table = pte_offset_map_lock(mm, pmd, address, &ptl); 2659 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
2659 if (!pte_none(*page_table)) 2660 if (!pte_none(*page_table))