From: Andrea Arcangeli Date: Thu, 13 Jan 2011 23:46:33 +0000 (-0800) Subject: thp: put_page: recheck PageHead after releasing the compound_lock X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a95a82e96c48270980dd248ccd5546f1b49e6f8a;p=linux-beck.git thp: put_page: recheck PageHead after releasing the compound_lock After releasing the compound_lock split_huge_page can still run and release the page before put_page_testzero runs. Signed-off-by: Andrea Arcangeli Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/swap.c b/mm/swap.c index 33f5292fe132..e0eeef940886 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -131,8 +131,12 @@ static void put_compound_page(struct page *page) atomic_dec(&page->_count); VM_BUG_ON(atomic_read(&page_head->_count) <= 0); compound_unlock_irqrestore(page_head, flags); - if (put_page_testzero(page_head)) - __put_compound_page(page_head); + if (put_page_testzero(page_head)) { + if (PageHead(page_head)) + __put_compound_page(page_head); + else + __put_single_page(page_head); + } } else { /* page_head is a dangling pointer */ VM_BUG_ON(PageTail(page));