Merge tag 'iwlwifi-next-for-kalle-2015-09-21' of git://git.kernel.org/pub/scm/linux...
[firefly-linux-kernel-4.4.55.git] / mm / memory-failure.c
index b0664c23838b8191ad4d0bd4463bb13524a147e0..95882692e747c2a534488190287e5954fba35d39 100644 (file)
@@ -130,27 +130,15 @@ static int hwpoison_filter_flags(struct page *p)
  * can only guarantee that the page either belongs to the memcg tasks, or is
  * a freed page.
  */
-#ifdef CONFIG_MEMCG_SWAP
+#ifdef CONFIG_MEMCG
 u64 hwpoison_filter_memcg;
 EXPORT_SYMBOL_GPL(hwpoison_filter_memcg);
 static int hwpoison_filter_task(struct page *p)
 {
-       struct mem_cgroup *mem;
-       struct cgroup_subsys_state *css;
-       unsigned long ino;
-
        if (!hwpoison_filter_memcg)
                return 0;
 
-       mem = try_get_mem_cgroup_from_page(p);
-       if (!mem)
-               return -EINVAL;
-
-       css = &mem->css;
-       ino = cgroup_ino(css->cgroup);
-       css_put(css);
-
-       if (ino != hwpoison_filter_memcg)
+       if (page_cgroup_ino(p) != hwpoison_filter_memcg)
                return -EINVAL;
 
        return 0;
@@ -1445,6 +1433,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.
@@ -1505,7 +1509,7 @@ static struct page *new_page(struct page *p, unsigned long private, int **x)
                return alloc_huge_page_node(page_hstate(compound_head(p)),
                                                   nid);
        else
-               return alloc_pages_exact_node(nid, GFP_HIGHUSER_MOVABLE, 0);
+               return __alloc_pages_node(nid, GFP_HIGHUSER_MOVABLE, 0);
 }
 
 /*