]>
Commit | Line | Data |
---|---|---|
0c074fcf GKH |
1 | From 750e8165f5e87b6a142be953640eabb13a9d350a Mon Sep 17 00:00:00 2001 |
2 | From: Hugh Dickins <hughd@google.com> | |
3 | Date: Wed, 16 Oct 2013 13:47:08 -0700 | |
4 | Subject: mm: fix BUG in __split_huge_page_pmd | |
5 | ||
6 | From: Hugh Dickins <hughd@google.com> | |
7 | ||
8 | commit 750e8165f5e87b6a142be953640eabb13a9d350a upstream. | |
9 | ||
10 | Occasionally 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 | ||
13 | It's invalid: we don't always have down_write of mmap_sem there: a racing | |
14 | do_huge_pmd_wp_page() might have copied-on-write to another huge page | |
15 | before our split_huge_page() got the anon_vma lock. | |
16 | ||
17 | Forget the BUG_ON, just go back and try again if this happens. | |
18 | ||
19 | Signed-off-by: Hugh Dickins <hughd@google.com> | |
20 | Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> | |
21 | Cc: Andrea Arcangeli <aarcange@redhat.com> | |
22 | Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> | |
23 | Cc: David Rientjes <rientjes@google.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@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, |