]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.27.36/mm-fix-anonymous-dirtying.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 2.6.27.36 / mm-fix-anonymous-dirtying.patch
1 From 1ac0cb5d0e22d5e483f56b2bc12172dec1cf7536 Mon Sep 17 00:00:00 2001
2 From: Hugh Dickins <hugh.dickins@tiscali.co.uk>
3 Date: Mon, 21 Sep 2009 17:03:29 -0700
4 Subject: mm: fix anonymous dirtying
5
6 From: Hugh Dickins <hugh.dickins@tiscali.co.uk>
7
8 commit 1ac0cb5d0e22d5e483f56b2bc12172dec1cf7536 upstream.
9
10 do_anonymous_page() has been wrong to dirty the pte regardless.
11 If it's not going to mark the pte writable, then it won't help
12 to mark it dirty here, and clogs up memory with pages which will
13 need swap instead of being thrown away. Especially wrong if no
14 overcommit is chosen, and this vma is not yet VM_ACCOUNTed -
15 we could exceed the limit and OOM despite no overcommit.
16
17 Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
18 Acked-by: Rik van Riel <riel@redhat.com>
19 Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
20 Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
21 Cc: Nick Piggin <npiggin@suse.de>
22 Cc: Mel Gorman <mel@csn.ul.ie>
23 Cc: Minchan Kim <minchan.kim@gmail.com>
24 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
25 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
27
28 ---
29 mm/memory.c | 3 ++-
30 1 file changed, 2 insertions(+), 1 deletion(-)
31
32 --- a/mm/memory.c
33 +++ b/mm/memory.c
34 @@ -2422,7 +2422,8 @@ static int do_anonymous_page(struct mm_s
35 goto oom_free_page;
36
37 entry = mk_pte(page, vma->vm_page_prot);
38 - entry = maybe_mkwrite(pte_mkdirty(entry), vma);
39 + if (vma->vm_flags & VM_WRITE)
40 + entry = pte_mkwrite(pte_mkdirty(entry));
41
42 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
43 if (!pte_none(*page_table))