mm/hwpoison: don't try to unpoison containment-failed pages
[firefly-linux-kernel-4.4.55.git] / mm / memory-failure.c
index b0664c23838b8191ad4d0bd4463bb13524a147e0..bba2d7c2c9ce43ee8cfba83024a4287925eedcd7 100644 (file)
@@ -1445,6 +1445,22 @@ int unpoison_memory(unsigned long pfn)
                return 0;
        }
 
+       if (page_count(page) > 1) {
+               pr_info("MCE: Someone grabs the hwpoison page %#lx\n", pfn);
+               return 0;
+       }
+
+       if (page_mapped(page)) {
+               pr_info("MCE: Someone maps the hwpoison page %#lx\n", pfn);
+               return 0;
+       }
+
+       if (page_mapping(page)) {
+               pr_info("MCE: the hwpoison page has non-NULL mapping %#lx\n",
+                       pfn);
+               return 0;
+       }
+
        /*
         * unpoison_memory() can encounter thp only when the thp is being
         * worked by memory_failure() and the page lock is not held yet.