Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
[deliverable/linux.git] / mm / memory-failure.c
index 1a56d63adf9c642eed15e5d9e276060e2f01a933..df0694c6adefccfafdc18b0ca7926b900f982234 100644 (file)
@@ -784,12 +784,12 @@ static struct page_state {
        { sc|dirty,     sc|dirty,       "dirty swapcache",      me_swapcache_dirty },
        { sc|dirty,     sc,             "clean swapcache",      me_swapcache_clean },
 
-       { unevict|dirty, unevict|dirty, "dirty unevictable LRU", me_pagecache_dirty },
-       { unevict,      unevict,        "clean unevictable LRU", me_pagecache_clean },
-
        { mlock|dirty,  mlock|dirty,    "dirty mlocked LRU",    me_pagecache_dirty },
        { mlock,        mlock,          "clean mlocked LRU",    me_pagecache_clean },
 
+       { unevict|dirty, unevict|dirty, "dirty unevictable LRU", me_pagecache_dirty },
+       { unevict,      unevict,        "clean unevictable LRU", me_pagecache_clean },
+
        { lru|dirty,    lru|dirty,      "dirty LRU",    me_pagecache_dirty },
        { lru|dirty,    lru,            "clean LRU",    me_pagecache_clean },
 
@@ -1021,6 +1021,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
        struct page *hpage;
        int res;
        unsigned int nr_pages;
+       unsigned long page_flags;
 
        if (!sysctl_memory_failure_recovery)
                panic("Memory failure from trap %d on page %lx", trapno, pfn);
@@ -1128,6 +1129,15 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
         */
        lock_page(hpage);
 
+       /*
+        * We use page flags to determine what action should be taken, but
+        * the flags can be modified by the error containment action.  One
+        * example is an mlocked page, where PG_mlocked is cleared by
+        * page_remove_rmap() in try_to_unmap_one(). So to determine page status
+        * correctly, we save a copy of the page flags at this time.
+        */
+       page_flags = p->flags;
+
        /*
         * unpoison always clear PG_hwpoison inside page lock
         */
@@ -1186,12 +1196,19 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
        }
 
        res = -EBUSY;
-       for (ps = error_states;; ps++) {
-               if ((p->flags & ps->mask) == ps->res) {
-                       res = page_action(ps, p, pfn);
+       /*
+        * The first check uses the current page flags which may not have any
+        * relevant information. The second check with the saved page flagss is
+        * carried out only if the first check can't determine the page status.
+        */
+       for (ps = error_states;; ps++)
+               if ((p->flags & ps->mask) == ps->res)
                        break;
-               }
-       }
+       if (!ps->mask)
+               for (ps = error_states;; ps++)
+                       if ((page_flags & ps->mask) == ps->res)
+                               break;
+       res = page_action(ps, p, pfn);
 out:
        unlock_page(hpage);
        return res;
@@ -1465,7 +1482,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
        unlock_page(hpage);
 
        /* Keep page count to indicate a given hugepage is isolated. */
-       ret = migrate_huge_page(hpage, new_page, MPOL_MF_MOVE_ALL, false,
+       ret = migrate_huge_page(hpage, new_page, MPOL_MF_MOVE_ALL,
                                MIGRATE_SYNC);
        put_page(hpage);
        if (ret) {
@@ -1597,11 +1614,10 @@ static int __soft_offline_page(struct page *page, int flags)
        if (!ret) {
                LIST_HEAD(pagelist);
                inc_zone_page_state(page, NR_ISOLATED_ANON +
-                                           page_is_file_cache(page));
+                                       page_is_file_cache(page));
                list_add(&page->lru, &pagelist);
                ret = migrate_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL,
-                                                       false, MIGRATE_SYNC,
-                                                       MR_MEMORY_FAILURE);
+                                       MIGRATE_SYNC, MR_MEMORY_FAILURE);
                if (ret) {
                        putback_lru_pages(&pagelist);
                        pr_info("soft offline: %#lx: migration failed %d, type %lx\n",
This page took 0.025557 seconds and 5 git commands to generate.