Skip to content

Commit

Permalink
mm/hwpoison: fix PageHWPoison test/set race
Browse files Browse the repository at this point in the history
There is a race between madvise_hwpoison path and memory_failure:

 CPU0					CPU1

madvise_hwpoison
get_user_pages_fast
PageHWPoison check (false)
					memory_failure
					TestSetPageHWPoison
soft_offline_page
PageHWPoison check (true)
return -EBUSY (without put_page)

Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Suggested-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Wanpeng Li authored and torvalds committed Sep 8, 2015
1 parent 7d1900c commit 1e0e635
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,8 @@ int soft_offline_page(struct page *page, int flags)

if (PageHWPoison(page)) {
pr_info("soft offline: %#lx page already poisoned\n", pfn);
if (flags & MF_COUNT_INCREASED)
put_page(page);
return -EBUSY;
}
if (!PageHuge(page) && PageTransHuge(hpage)) {
Expand Down

0 comments on commit 1e0e635

Please sign in to comment.