Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e0e635b authored by Wanpeng Li's avatar Wanpeng Li Committed by Linus Torvalds
Browse files

mm/hwpoison: fix PageHWPoison test/set race



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: default avatarWanpeng Li <wanpeng.li@hotmail.com>
Suggested-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7d1900c7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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)) {