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

Commit 1668bfd5 authored by Wu Fengguang's avatar Wu Fengguang Committed by Andi Kleen
Browse files

HWPOISON: abort on failed unmap



Don't try to isolate a still mapped page. Otherwise we will hit the
BUG_ON(page_mapped(page)) in __remove_from_page_cache().

Signed-off-by: default avatarWu Fengguang <fengguang.wu@intel.com>
Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
parent 82ba011b
Loading
Loading
Loading
Loading
+15 −5
Original line number Original line Diff line number Diff line
@@ -655,7 +655,7 @@ static int page_action(struct page_state *ps, struct page *p,
 * Do all that is necessary to remove user space mappings. Unmap
 * Do all that is necessary to remove user space mappings. Unmap
 * the pages and send SIGBUS to the processes if the data was dirty.
 * the pages and send SIGBUS to the processes if the data was dirty.
 */
 */
static void hwpoison_user_mappings(struct page *p, unsigned long pfn,
static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
				  int trapno)
				  int trapno)
{
{
	enum ttu_flags ttu = TTU_UNMAP | TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS;
	enum ttu_flags ttu = TTU_UNMAP | TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS;
@@ -665,15 +665,18 @@ static void hwpoison_user_mappings(struct page *p, unsigned long pfn,
	int i;
	int i;
	int kill = 1;
	int kill = 1;


	if (PageReserved(p) || PageCompound(p) || PageSlab(p) || PageKsm(p))
	if (PageReserved(p) || PageSlab(p))
		return;
		return SWAP_SUCCESS;


	/*
	/*
	 * This check implies we don't kill processes if their pages
	 * This check implies we don't kill processes if their pages
	 * are in the swap cache early. Those are always late kills.
	 * are in the swap cache early. Those are always late kills.
	 */
	 */
	if (!page_mapped(p))
	if (!page_mapped(p))
		return;
		return SWAP_SUCCESS;

	if (PageCompound(p) || PageKsm(p))
		return SWAP_FAIL;


	if (PageSwapCache(p)) {
	if (PageSwapCache(p)) {
		printk(KERN_ERR
		printk(KERN_ERR
@@ -735,6 +738,8 @@ static void hwpoison_user_mappings(struct page *p, unsigned long pfn,
	 */
	 */
	kill_procs_ao(&tokill, !!PageDirty(p), trapno,
	kill_procs_ao(&tokill, !!PageDirty(p), trapno,
		      ret != SWAP_SUCCESS, pfn);
		      ret != SWAP_SUCCESS, pfn);

	return ret;
}
}


int __memory_failure(unsigned long pfn, int trapno, int flags)
int __memory_failure(unsigned long pfn, int trapno, int flags)
@@ -807,8 +812,13 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)


	/*
	/*
	 * Now take care of user space mappings.
	 * Now take care of user space mappings.
	 * Abort on fail: __remove_from_page_cache() assumes unmapped page.
	 */
	 */
	hwpoison_user_mappings(p, pfn, trapno);
	if (hwpoison_user_mappings(p, pfn, trapno) != SWAP_SUCCESS) {
		printk(KERN_ERR "MCE %#lx: cannot unmap page, give up\n", pfn);
		res = -EBUSY;
		goto out;
	}


	/*
	/*
	 * Torn down by someone else?
	 * Torn down by someone else?