linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* mm: fix BUG in __split_huge_page_pmd
@ 2013-10-15 11:08 Hugh Dickins
  2013-10-15 11:32 ` Kirill A. Shutemov
  2013-10-15 14:34 ` Andrea Arcangeli
  0 siblings, 2 replies; 12+ messages in thread
From: Hugh Dickins @ 2013-10-15 11:08 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andrea Arcangeli, David Rientjes, Kirill A. Shutemov,
	Naoya Horiguchi, linux-kernel, linux-mm

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>
Cc: stable@vger.kernel.org
---

 mm/huge_memory.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

--- 3.12-rc5/mm/huge_memory.c	2013-09-16 17:37:56.811072270 -0700
+++ linux/mm/huge_memory.c	2013-10-15 03:40:02.044138488 -0700
@@ -2697,6 +2697,7 @@ void __split_huge_page_pmd(struct vm_are
 
 	mmun_start = haddr;
 	mmun_end   = haddr + HPAGE_PMD_SIZE;
+again:
 	mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
 	spin_lock(&mm->page_table_lock);
 	if (unlikely(!pmd_trans_huge(*pmd))) {
@@ -2719,7 +2720,14 @@ void __split_huge_page_pmd(struct vm_are
 	split_huge_page(page);
 
 	put_page(page);
-	BUG_ON(pmd_trans_huge(*pmd));
+
+	/*
+	 * We don't always have down_write of mmap_sem here: 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.
+	 */
+	if (unlikely(pmd_trans_huge(*pmd)))
+		goto again;
 }
 
 void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address,

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-10-15 20:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-15 11:08 mm: fix BUG in __split_huge_page_pmd Hugh Dickins
2013-10-15 11:32 ` Kirill A. Shutemov
2013-10-15 14:41   ` Andrea Arcangeli
2013-10-15 14:34 ` Andrea Arcangeli
2013-10-15 14:48   ` Kirill A. Shutemov
2013-10-15 15:58     ` Andrea Arcangeli
2013-10-15 17:53     ` Hugh Dickins
2013-10-15 18:55       ` Andrea Arcangeli
2013-10-15 19:28         ` Naoya Horiguchi
2013-10-15 19:44           ` Andrea Arcangeli
2013-10-15 20:16             ` Naoya Horiguchi
2013-10-15 20:30               ` Andrea Arcangeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).