diff options
author | Hugh Dickins <hughd@google.com> | 2013-10-16 16:47:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-04 07:31:06 -0500 |
commit | 7ed008638ee15991b79d8867d382e141fee89a69 (patch) | |
tree | 5dd4c5529fd27a717360cdd7e4a2401579d83895 /mm | |
parent | fe0051d83cb951fbeab6712633ca2e31de22ee11 (diff) |
mm: fix BUG in __split_huge_page_pmd
commit 750e8165f5e87b6a142be953640eabb13a9d350a upstream.
Occasionally we hit the BUG_ON(pmd_trans_huge(*pmd)) at the end of
__split_huge_page_pmd(): seen when doing madvise(,,MADV_DONTNEED).
It's invalid: we don't always have down_write of mmap_sem there: a racing
do_huge_pmd_wp_page() might have copied-on-write to another huge page
before our split_huge_page() got the anon_vma lock.
Forget the BUG_ON, just go back and try again if this happens.
Signed-off-by: Hugh Dickins <hughd@google.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/huge_memory.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b92d0ce428b1..0164b09c1e99 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -2699,6 +2699,7 @@ void __split_huge_page_pmd(struct vm_area_struct *vma, unsigned long address, | |||
2699 | 2699 | ||
2700 | mmun_start = haddr; | 2700 | mmun_start = haddr; |
2701 | mmun_end = haddr + HPAGE_PMD_SIZE; | 2701 | mmun_end = haddr + HPAGE_PMD_SIZE; |
2702 | again: | ||
2702 | mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); | 2703 | mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); |
2703 | spin_lock(&mm->page_table_lock); | 2704 | spin_lock(&mm->page_table_lock); |
2704 | if (unlikely(!pmd_trans_huge(*pmd))) { | 2705 | if (unlikely(!pmd_trans_huge(*pmd))) { |
@@ -2721,7 +2722,14 @@ void __split_huge_page_pmd(struct vm_area_struct *vma, unsigned long address, | |||
2721 | split_huge_page(page); | 2722 | split_huge_page(page); |
2722 | 2723 | ||
2723 | put_page(page); | 2724 | put_page(page); |
2724 | BUG_ON(pmd_trans_huge(*pmd)); | 2725 | |
2726 | /* | ||
2727 | * We don't always have down_write of mmap_sem here: a racing | ||
2728 | * do_huge_pmd_wp_page() might have copied-on-write to another | ||
2729 | * huge page before our split_huge_page() got the anon_vma lock. | ||
2730 | */ | ||
2731 | if (unlikely(pmd_trans_huge(*pmd))) | ||
2732 | goto again; | ||
2725 | } | 2733 | } |
2726 | 2734 | ||
2727 | void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address, | 2735 | void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address, |