]> Pileus Git - ~andy/linux/blobdiff - mm/memory-failure.c
mm/hwpoison: fix race against poison thp
[~andy/linux] / mm / memory-failure.c
index 7b5d32507c350a062d5c237e8344ba2f757b370a..32351ec32048229792ae3395a902ae0bcb57bdc4 100644 (file)
@@ -1342,6 +1342,16 @@ int unpoison_memory(unsigned long 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.
+        * In such case, we yield to memory_failure() and make unpoison fail.
+        */
+       if (PageTransHuge(page)) {
+               pr_info("MCE: Memory failure is now running on %#lx\n", pfn);
+                       return 0;
+       }
+
        nr_pages = 1 << compound_order(page);
 
        if (!get_page_unless_zero(page)) {