]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
cb5f79f8d497caa28606386c3c3814668579435a
[thirdparty/kernel/stable-queue.git] /
1 From 32b154c0b0bae2879bf4e549d861caf1759a3546 Mon Sep 17 00:00:00 2001
2 From: Mel Gorman <mel@csn.ul.ie>
3 Date: Thu, 28 May 2009 14:34:37 -0700
4 Subject: x86: ignore VM_LOCKED when determining if hugetlb-backed page tables can be shared or not
5
6 From: Mel Gorman <mel@csn.ul.ie>
7
8 commit 32b154c0b0bae2879bf4e549d861caf1759a3546 upstream.
9
10 Addresses http://bugzilla.kernel.org/show_bug.cgi?id=13302
11
12 On x86 and x86-64, it is possible that page tables are shared beween
13 shared mappings backed by hugetlbfs. As part of this,
14 page_table_shareable() checks a pair of vma->vm_flags and they must match
15 if they are to be shared. All VMA flags are taken into account, including
16 VM_LOCKED.
17
18 The problem is that VM_LOCKED is cleared on fork(). When a process with a
19 shared memory segment forks() to exec() a helper, there will be shared
20 VMAs with different flags. The impact is that the shared segment is
21 sometimes considered shareable and other times not, depending on what
22 process is checking.
23
24 What happens is that the segment page tables are being shared but the
25 count is inaccurate depending on the ordering of events. As the page
26 tables are freed with put_page(), bad pmd's are found when some of the
27 children exit. The hugepage counters also get corrupted and the Total and
28 Free count will no longer match even when all the hugepage-backed regions
29 are freed. This requires a reboot of the machine to "fix".
30
31 This patch addresses the problem by comparing all flags except VM_LOCKED
32 when deciding if pagetables should be shared or not for hugetlbfs-backed
33 mapping.
34
35 Signed-off-by: Mel Gorman <mel@csn.ul.ie>
36 Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
37 Cc: Ingo Molnar <mingo@elte.hu>
38 Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
39 Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
40 Cc: <starlight@binnacle.cx>
41 Cc: Eric B Munson <ebmunson@us.ibm.com>
42 Cc: Adam Litke <agl@us.ibm.com>
43 Cc: Andy Whitcroft <apw@canonical.com>
44 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
45 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
46 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
47
48 ---
49 arch/x86/mm/hugetlbpage.c | 6 +++++-
50 1 file changed, 5 insertions(+), 1 deletion(-)
51
52 --- a/arch/x86/mm/hugetlbpage.c
53 +++ b/arch/x86/mm/hugetlbpage.c
54 @@ -26,12 +26,16 @@ static unsigned long page_table_shareabl
55 unsigned long sbase = saddr & PUD_MASK;
56 unsigned long s_end = sbase + PUD_SIZE;
57
58 + /* Allow segments to share if only one is marked locked */
59 + unsigned long vm_flags = vma->vm_flags & ~VM_LOCKED;
60 + unsigned long svm_flags = svma->vm_flags & ~VM_LOCKED;
61 +
62 /*
63 * match the virtual addresses, permission and the alignment of the
64 * page table page.
65 */
66 if (pmd_index(addr) != pmd_index(saddr) ||
67 - vma->vm_flags != svma->vm_flags ||
68 + vm_flags != svm_flags ||
69 sbase < svma->vm_start || svma->vm_end < s_end)
70 return 0;
71