Commit 357670f7 authored by Miaohe Lin's avatar Miaohe Lin Committed by Linus Torvalds
Browse files

mm/memory-failure.c: rework the try_to_unmap logic in hwpoison_user_mappings()

Only for hugetlb pages in shared mappings, try_to_unmap should take
semaphore in write mode here.  Rework the code to make it clear.

Link: https://lkml.kernel.org/r/20220218090118.1105-7-linmiaohe@huawei.com


Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Acked-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 67ff51c6
Loading
Loading
Loading
Loading
+15 −19
Original line number Diff line number Diff line
@@ -1404,10 +1404,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
	if (kill)
		collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED);

	if (!PageHuge(hpage)) {
		try_to_unmap(hpage, ttu);
	} else {
		if (!PageAnon(hpage)) {
	if (PageHuge(hpage) && !PageAnon(hpage)) {
		/*
		 * For hugetlb pages in shared mappings, try_to_unmap
		 * could potentially call huge_pmd_unshare.  Because of
@@ -1424,7 +1421,6 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
	} else {
		try_to_unmap(hpage, ttu);
	}
	}

	unmap_success = !page_mapped(hpage);
	if (!unmap_success)