Commit a95a82e96c48270980dd248ccd5546f1b49e6f8a
Committed by
Linus Torvalds
1 parent
9180706344
Exists in
master
and in
4 other branches
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 <aarcange@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 6 additions and 2 deletions Side-by-side Diff
mm/swap.c
... | ... | @@ -131,8 +131,12 @@ |
131 | 131 | atomic_dec(&page->_count); |
132 | 132 | VM_BUG_ON(atomic_read(&page_head->_count) <= 0); |
133 | 133 | compound_unlock_irqrestore(page_head, flags); |
134 | - if (put_page_testzero(page_head)) | |
135 | - __put_compound_page(page_head); | |
134 | + if (put_page_testzero(page_head)) { | |
135 | + if (PageHead(page_head)) | |
136 | + __put_compound_page(page_head); | |
137 | + else | |
138 | + __put_single_page(page_head); | |
139 | + } | |
136 | 140 | } else { |
137 | 141 | /* page_head is a dangling pointer */ |
138 | 142 | VM_BUG_ON(PageTail(page)); |