]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - mm/memory-failure.c
mm/memory-failure.c-failure: send right signal code to correct thread
[mirror_ubuntu-artful-kernel.git] / mm / memory-failure.c
index 9ccef39a9de261c96f4e5775d7dca48b63d4d133..89ad452182bb43c1568df7c383206eefa31d692a 100644 (file)
@@ -204,9 +204,9 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
 #endif
        si.si_addr_lsb = compound_order(compound_head(page)) + PAGE_SHIFT;
 
-       if ((flags & MF_ACTION_REQUIRED) && t == current) {
+       if ((flags & MF_ACTION_REQUIRED) && t->mm == current->mm) {
                si.si_code = BUS_MCEERR_AR;
-               ret = force_sig_info(SIGBUS, &si, t);
+               ret = force_sig_info(SIGBUS, &si, current);
        } else {
                /*
                 * Don't use force here, it's convenient if the signal
@@ -1132,11 +1132,6 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
                }
        }
 
-       /*
-        * Lock the page and wait for writeback to finish.
-        * It's very difficult to mess with pages currently under IO
-        * and in many cases impossible, so we just avoid it here.
-        */
        lock_page(hpage);
 
        /*
@@ -1186,6 +1181,10 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
        if (PageHuge(p))
                set_page_hwpoison_huge_page(hpage);
 
+       /*
+        * It's very difficult to mess with pages currently under IO
+        * and in many cases impossible, so we just avoid it here.
+        */
        wait_on_page_writeback(p);
 
        /*
@@ -1298,7 +1297,7 @@ static void memory_failure_work_func(struct work_struct *work)
        unsigned long proc_flags;
        int gotten;
 
-       mf_cpu = &__get_cpu_var(memory_failure_cpu);
+       mf_cpu = this_cpu_ptr(&memory_failure_cpu);
        for (;;) {
                spin_lock_irqsave(&mf_cpu->lock, proc_flags);
                gotten = kfifo_get(&mf_cpu->fifo, &entry);
@@ -1503,7 +1502,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
 
        /* Keep page count to indicate a given hugepage is isolated. */
        list_move(&hpage->lru, &pagelist);
-       ret = migrate_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL,
+       ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL,
                                MIGRATE_SYNC, MR_MEMORY_FAILURE);
        if (ret) {
                pr_info("soft offline: %#lx: migration failed %d, type %lx\n",
@@ -1584,7 +1583,7 @@ static int __soft_offline_page(struct page *page, int flags)
                inc_zone_page_state(page, NR_ISOLATED_ANON +
                                        page_is_file_cache(page));
                list_add(&page->lru, &pagelist);
-               ret = migrate_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL,
+               ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL,
                                        MIGRATE_SYNC, MR_MEMORY_FAILURE);
                if (ret) {
                        if (!list_empty(&pagelist)) {
@@ -1664,11 +1663,7 @@ int soft_offline_page(struct page *page, int flags)
                }
        }
 
-       /*
-        * The lock_memory_hotplug prevents a race with memory hotplug.
-        * This is a big hammer, a better would be nicer.
-        */
-       lock_memory_hotplug();
+       get_online_mems();
 
        /*
         * Isolate the page, so that it doesn't get reallocated if it
@@ -1679,7 +1674,7 @@ int soft_offline_page(struct page *page, int flags)
                set_migratetype_isolate(page, true);
 
        ret = get_any_page(page, pfn, flags);
-       unlock_memory_hotplug();
+       put_online_mems();
        if (ret > 0) { /* for in-use pages */
                if (PageHuge(page))
                        ret = soft_offline_huge_page(page, flags);