]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.10.18/mm-fix-bug-in-__split_huge_page_pmd.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.10.18 / mm-fix-bug-in-__split_huge_page_pmd.patch
CommitLineData
0c074fcf
GKH
1From 750e8165f5e87b6a142be953640eabb13a9d350a Mon Sep 17 00:00:00 2001
2From: Hugh Dickins <hughd@google.com>
3Date: Wed, 16 Oct 2013 13:47:08 -0700
4Subject: mm: fix BUG in __split_huge_page_pmd
5
6From: Hugh Dickins <hughd@google.com>
7
8commit 750e8165f5e87b6a142be953640eabb13a9d350a upstream.
9
10Occasionally we hit the BUG_ON(pmd_trans_huge(*pmd)) at the end of
11__split_huge_page_pmd(): seen when doing madvise(,,MADV_DONTNEED).
12
13It's invalid: we don't always have down_write of mmap_sem there: a racing
14do_huge_pmd_wp_page() might have copied-on-write to another huge page
15before our split_huge_page() got the anon_vma lock.
16
17Forget the BUG_ON, just go back and try again if this happens.
18
19Signed-off-by: Hugh Dickins <hughd@google.com>
20Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
21Cc: Andrea Arcangeli <aarcange@redhat.com>
22Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
23Cc: David Rientjes <rientjes@google.com>
24Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
25Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
26Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28---
29 mm/huge_memory.c | 10 +++++++++-
30 1 file changed, 9 insertions(+), 1 deletion(-)
31
32--- a/mm/huge_memory.c
33+++ b/mm/huge_memory.c
34@@ -2699,6 +2699,7 @@ void __split_huge_page_pmd(struct vm_are
35
36 mmun_start = haddr;
37 mmun_end = haddr + HPAGE_PMD_SIZE;
38+again:
39 mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
40 spin_lock(&mm->page_table_lock);
41 if (unlikely(!pmd_trans_huge(*pmd))) {
42@@ -2721,7 +2722,14 @@ void __split_huge_page_pmd(struct vm_are
43 split_huge_page(page);
44
45 put_page(page);
46- BUG_ON(pmd_trans_huge(*pmd));
47+
48+ /*
49+ * We don't always have down_write of mmap_sem here: a racing
50+ * do_huge_pmd_wp_page() might have copied-on-write to another
51+ * huge page before our split_huge_page() got the anon_vma lock.
52+ */
53+ if (unlikely(pmd_trans_huge(*pmd)))
54+ goto again;
55 }
56
57 void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address,